Skip to content

Commit e27062c

Browse files
committed
WIP
1 parent 2601054 commit e27062c

File tree

1 file changed

+11
-3
lines changed

1 file changed

+11
-3
lines changed

test/asynchronous/test_async_cancellation.py

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -17,17 +17,23 @@
1717

1818
import asyncio
1919
import sys
20+
from test.utils import async_get_pool, get_pool, one
2021

2122
sys.path[0:0] = [""]
2223

23-
from test.asynchronous import AsyncIntegrationTest
24+
from test.asynchronous import AsyncIntegrationTest, connected
2425

2526

2627
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+
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)

0 commit comments

Comments
 (0)