File tree Expand file tree Collapse file tree 4 files changed +11
-17
lines changed Expand file tree Collapse file tree 4 files changed +11
-17
lines changed Original file line number Diff line number Diff line change 28
28
sys .path [0 :0 ] = ["" ]
29
29
30
30
from test .asynchronous import AsyncIntegrationTest , async_client_context , unittest
31
- from test .utils import joinall , one
31
+ from test .utils import async_joinall , one
32
32
33
33
import gridfs
34
34
from bson .binary import Binary
@@ -230,10 +230,7 @@ async def test_threaded_reads(self):
230
230
tasks .append (JustRead (self .fs , 10 , results ))
231
231
await tasks [i ].start ()
232
232
233
- if _IS_SYNC :
234
- joinall (tasks )
235
- else :
236
- await asyncio .wait ([t .task for t in tasks if t .task is not None ])
233
+ await async_joinall (tasks )
237
234
238
235
self .assertEqual (100 * [b"hello" ], results )
239
236
@@ -243,10 +240,7 @@ async def test_threaded_writes(self):
243
240
tasks .append (JustWrite (self .fs , 10 ))
244
241
await tasks [i ].start ()
245
242
246
- if _IS_SYNC :
247
- joinall (tasks )
248
- else :
249
- await asyncio .wait ([t .task for t in tasks if t .task is not None ])
243
+ await async_joinall (tasks )
250
244
251
245
f = await self .fs .get_last_version ("test" )
252
246
self .assertEqual (await f .read (), b"hello" )
Original file line number Diff line number Diff line change @@ -228,10 +228,7 @@ def test_threaded_reads(self):
228
228
tasks .append (JustRead (self .fs , 10 , results ))
229
229
tasks [i ].start ()
230
230
231
- if _IS_SYNC :
232
- joinall (tasks )
233
- else :
234
- asyncio .wait ([t .task for t in tasks if t .task is not None ])
231
+ joinall (tasks )
235
232
236
233
self .assertEqual (100 * [b"hello" ], results )
237
234
@@ -241,10 +238,7 @@ def test_threaded_writes(self):
241
238
tasks .append (JustWrite (self .fs , 10 ))
242
239
tasks [i ].start ()
243
240
244
- if _IS_SYNC :
245
- joinall (tasks )
246
- else :
247
- asyncio .wait ([t .task for t in tasks if t .task is not None ])
241
+ joinall (tasks )
248
242
249
243
f = self .fs .get_last_version ("test" )
250
244
self .assertEqual (f .read (), b"hello" )
Original file line number Diff line number Diff line change @@ -666,6 +666,11 @@ def joinall(threads):
666
666
assert not t .is_alive (), "Thread %s hung" % t
667
667
668
668
669
+ async def async_joinall (tasks ):
670
+ """Join threads with a 5-minute timeout, assert joins succeeded"""
671
+ await asyncio .wait ([t .task for t in tasks if t is not None ], timeout = 300 )
672
+
673
+
669
674
def wait_until (predicate , success_description , timeout = 10 ):
670
675
"""Wait up to 10 seconds (by default) for predicate to be true.
671
676
Original file line number Diff line number Diff line change 124
124
"AsyncMockPool" : "MockPool" ,
125
125
"StopAsyncIteration" : "StopIteration" ,
126
126
"create_async_event" : "create_event" ,
127
+ "async_joinall" : "joinall" ,
127
128
}
128
129
129
130
docstring_replacements : dict [tuple [str , str ], str ] = {
You can’t perform that action at this time.
0 commit comments