(self)
| 448 | self.assertEqual(pool._queue.qsize(), 1) |
| 449 | |
| 450 | async def test_pool_handles_task_cancel_in_release(self): |
| 451 | # Use SlowResetConnectionPool to simulate |
| 452 | # the Task.cancel() and __aexit__ race. |
| 453 | pool = await self.create_pool(database='postgres', |
| 454 | init_size=1, min_size=1, max_size=1, |
| 455 | connection_class=SlowResetConnection) |
| 456 | |
| 457 | async def worker(): |
| 458 | async with pool.acquire(): |
| 459 | pass |
| 460 | |
| 461 | task = self.loop.create_task(worker()) |
| 462 | # Let the worker() run. |
| 463 | await asyncio.sleep(0.1) |
| 464 | # Cancel the worker. |
| 465 | task.cancel() |
| 466 | # Wait to make sure the cleanup has completed. |
| 467 | await asyncio.sleep(0.4) |
| 468 | # Check that the connection has been returned to the pool. |
| 469 | self.assertEqual(pool._queue.qsize(), 1) |
| 470 | |
| 471 | async def test_pool_handles_query_cancel_in_release(self): |
| 472 | # Use SlowResetConnectionPool to simulate |
nothing calls this directly
no test coverage detected