| 1494 | await pool.close() |
| 1495 | |
| 1496 | async def test_pool_remote_close(self): |
| 1497 | pool = await self.create_pool(init_size=1, min_size=1, max_size=1) |
| 1498 | backend_pid_fut = self.loop.create_future() |
| 1499 | |
| 1500 | async def worker(): |
| 1501 | async with pool.acquire() as conn: |
| 1502 | pool_backend_pid = await conn.fetchval( |
| 1503 | 'SELECT pg_backend_pid()') |
| 1504 | backend_pid_fut.set_result(pool_backend_pid) |
| 1505 | await asyncio.sleep(0.2) |
| 1506 | |
| 1507 | task = self.loop.create_task(worker()) |
| 1508 | try: |
| 1509 | conn = await self.connect() |
| 1510 | backend_pid = await backend_pid_fut |
| 1511 | await conn.execute('SELECT pg_terminate_backend($1)', backend_pid) |
| 1512 | finally: |
| 1513 | await conn.close() |
| 1514 | |
| 1515 | await task |
| 1516 | |
| 1517 | # Check that connection_lost has released the pool holder. |
| 1518 | conn = await pool.acquire(timeout=POOL_NOMINAL_TIMEOUT) |
| 1519 | await pool.release(conn) |
| 1520 | |
| 1521 | async def test_pool_release_after_protocol_abort(self): |
| 1522 | pool = await self.create_pool(init_size=1, min_size=0, max_size=1) |