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
@@ -82,10 +83,26 @@ async def gather_test():
8283
8384 def test_upload_annotations_in_running_event_loop (self ):
8485 async def _test ():
85- sa .attach_items (self .PROJECT_NAME , self .ATTACH_PAYLOAD )
8686 annotations = sa .upload_annotations (
8787 self .PROJECT_NAME , annotations = self .UPLOAD_PAYLOAD
8888 )
8989 assert len (annotations ["succeeded" ]) == 4
9090
9191 asyncio .run (_test ())
92+
93+ def test_upload_in_threads (self ):
94+ def _test ():
95+ annotations = sa .upload_annotations (
96+ self .PROJECT_NAME , annotations = self .UPLOAD_PAYLOAD
97+ )
98+ assert len (annotations ["succeeded" ]) == 4
99+ return True
100+
101+ with concurrent .futures .ThreadPoolExecutor (max_workers = 8 ) as executor :
102+ futures = []
103+ for i in range (8 ):
104+ futures .append (executor .submit (_test ))
105+ results = []
106+ for f in concurrent .futures .as_completed (futures ):
107+ results .append (f .result ())
108+ assert all (results )
You can’t perform that action at this time.
0 commit comments