File tree Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Expand file tree Collapse file tree 1 file changed +11
-3
lines changed Original file line number Diff line number Diff line change 17
17
18
18
import asyncio
19
19
import sys
20
+ from test .utils import async_get_pool , get_pool , one
20
21
21
22
sys .path [0 :0 ] = ["" ]
22
23
23
- from test .asynchronous import AsyncIntegrationTest
24
+ from test .asynchronous import AsyncIntegrationTest , connected
24
25
25
26
26
27
class TestAsyncCancellation (AsyncIntegrationTest ):
27
- async def test_async_cancellation (self ):
28
+ async def test_async_cancellation_does_not_close_connection (self ):
29
+ client = await self .async_rs_or_single_client (maxPoolSize = 1 , retryReads = False )
30
+ pool = await async_get_pool (client )
31
+ await connected (client )
32
+ conn = one (pool .conns )
33
+
28
34
async def task ():
29
35
while True :
30
- await self . client .db .test .insert_one ({"x" : 1 })
36
+ await client .db .test .insert_one ({"x" : 1 })
31
37
await asyncio .sleep (0.005 )
32
38
33
39
task = asyncio .create_task (task ())
@@ -38,3 +44,5 @@ async def task():
38
44
task .cancel ()
39
45
with self .assertRaises (asyncio .CancelledError ):
40
46
await task
47
+
48
+ self .assertFalse (conn .closed )
You can’t perform that action at this time.
0 commit comments