File tree Expand file tree Collapse file tree 3 files changed +23
-5
lines changed
Expand file tree Collapse file tree 3 files changed +23
-5
lines changed Original file line number Diff line number Diff line change 22import copy
33import io
44import json
5+ import logging
56import os
67import sys
78import warnings
6364from lib .core .types import Project
6465from lib .infrastructure .utils import extract_project_folder
6566from lib .infrastructure .validators import wrap_error
66- import logging
67+
68+ import nest_asyncio
69+
70+ nest_asyncio .apply ()
6771
6872logger = logging .getLogger ("sa" )
6973
Original file line number Diff line number Diff line change 1- import nest_asyncio
21from lib .core .usecases .annotations import * # noqa: F403 F401
32from lib .core .usecases .classes import * # noqa: F403 F401
43from lib .core .usecases .custom_fields import * # noqa: F403 F401
87from lib .core .usecases .items import * # noqa: F403 F401
98from lib .core .usecases .models import * # noqa: F403 F401
109from lib .core .usecases .projects import * # noqa: F403 F401
11-
12- nest_asyncio .apply ()
Original file line number Diff line number Diff line change 11import asyncio
2+ import concurrent .futures
23from unittest import TestCase
34
45from superannotate import SAClient
@@ -81,10 +82,26 @@ async def gather_test():
8182
8283 def test_upload_annotations_in_running_event_loop (self ):
8384 async def _test ():
84- sa .attach_items (self .PROJECT_NAME , self .ATTACH_PAYLOAD )
8585 annotations = sa .upload_annotations (
8686 self .PROJECT_NAME , annotations = self .UPLOAD_PAYLOAD
8787 )
8888 assert len (annotations ["succeeded" ]) == 4
8989
9090 asyncio .run (_test ())
91+
92+ def test_upload_in_threads (self ):
93+ def _test ():
94+ annotations = sa .upload_annotations (
95+ self .PROJECT_NAME , annotations = self .UPLOAD_PAYLOAD
96+ )
97+ assert len (annotations ["succeeded" ]) == 4
98+ return True
99+
100+ with concurrent .futures .ThreadPoolExecutor (max_workers = 8 ) as executor :
101+ futures = []
102+ for i in range (8 ):
103+ futures .append (executor .submit (_test ))
104+ results = []
105+ for f in concurrent .futures .as_completed (futures ):
106+ results .append (f .result ())
107+ assert all (results )
You can’t perform that action at this time.
0 commit comments