MCPcopy Create free account
hub / github.com/MagicStack/asyncpg / test_pool_handles_asyncgen_finalization

Method test_pool_handles_asyncgen_finalization

tests/test_pool.py:1338–1357  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

1336 del iterator
1337
1338 async def test_pool_handles_asyncgen_finalization(self):
1339 pool = await self.create_pool(database='postgres',
1340 init_size=1, min_size=1, max_size=1)
1341
1342 locals_ = {}
1343 exec(textwrap.dedent('''\
1344 async def iterate(con):
1345 for record in await con.fetch("SELECT 1"):
1346 yield record
1347 '''), globals(), locals_)
1348 iterate = locals_['iterate']
1349
1350 class MyException(Exception):
1351 pass
1352
1353 with self.assertRaises(MyException):
1354 async with pool.acquire() as con:
1355 async with con.transaction():
1356 async for _ in iterate(con): # noqa
1357 raise MyException()
1358
1359 async def test_pool_close_waits_for_release(self):
1360 pool = await self.create_pool(database='postgres',

Callers

nothing calls this directly

Calls 4

MyExceptionClass · 0.85
transactionMethod · 0.80
create_poolMethod · 0.45
acquireMethod · 0.45

Tested by

no test coverage detected