MCPcopy
hub / github.com/MagicStack/asyncpg / test_timeout_04

Method test_timeout_04

tests/test_timeout.py:48–63  ·  view source on GitHub ↗
(self)

Source from the content-addressed store, hash-verified

46 self.assertEqual(await self.con.fetch('select 1'), [(1,)])
47
48 async def test_timeout_04(self):
49 st = await self.con.prepare('select pg_sleep(10)', timeout=0.1)
50 with self.assertRaises(asyncio.TimeoutError), \
51 self.assertRunUnder(MAX_RUNTIME):
52 async with self.con.transaction():
53 async for _ in st.cursor(timeout=0.1): # NOQA
54 pass
55 self.assertEqual(await self.con.fetch('select 1'), [(1,)])
56
57 st = await self.con.prepare('select pg_sleep(10)', timeout=0.1)
58 async with self.con.transaction():
59 cur = await st.cursor()
60 with self.assertRaises(asyncio.TimeoutError), \
61 self.assertRunUnder(MAX_RUNTIME):
62 await cur.fetch(1, timeout=0.1)
63 self.assertEqual(await self.con.fetch('select 1'), [(1,)])
64
65 async def test_timeout_05(self):
66 # Stress-test timeouts - try to trigger a race condition

Callers

nothing calls this directly

Calls 5

prepareMethod · 0.80
assertRunUnderMethod · 0.80
transactionMethod · 0.80
cursorMethod · 0.45
fetchMethod · 0.45

Tested by

no test coverage detected