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

Method test_pool_handles_asyncgen_finalization

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

Source from the content-addressed store, hash-verified

832 del iterator
833
834 async def test_pool_handles_asyncgen_finalization(self):
835 pool = await self.create_pool(database='postgres',
836 min_size=1, max_size=1)
837
838 locals_ = {}
839 exec(textwrap.dedent('''\
840 async def iterate(con):
841 for record in await con.fetch("SELECT 1"):
842 yield record
843 '''), globals(), locals_)
844 iterate = locals_['iterate']
845
846 class MyException(Exception):
847 pass
848
849 with self.assertRaises(MyException):
850 async with pool.acquire() as con:
851 async with con.transaction():
852 async for _ in iterate(con): # noqa
853 raise MyException()
854
855 async def test_pool_close_waits_for_release(self):
856 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