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 1717
1818import asyncio
1919import sys
20+ from test .utils import async_get_pool , get_pool , one
2021
2122sys .path [0 :0 ] = ["" ]
2223
23- from test .asynchronous import AsyncIntegrationTest
24+ from test .asynchronous import AsyncIntegrationTest , connected
2425
2526
2627class 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+
2834 async def task ():
2935 while True :
30- await self . client .db .test .insert_one ({"x" : 1 })
36+ await client .db .test .insert_one ({"x" : 1 })
3137 await asyncio .sleep (0.005 )
3238
3339 task = asyncio .create_task (task ())
@@ -38,3 +44,5 @@ async def task():
3844 task .cancel ()
3945 with self .assertRaises (asyncio .CancelledError ):
4046 await task
47+
48+ self .assertFalse (conn .closed )
You can’t perform that action at this time.
0 commit comments