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

Method test_pool_max_inactive_time_02

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

Source from the content-addressed store, hash-verified

708 self.assertIs(pool._holders[0]._con, con)
709
710 async def test_pool_max_inactive_time_02(self):
711 async with self.create_pool(
712 database='postgres', init_size=1, min_size=0, max_size=1,
713 max_inactive_connection_lifetime=0.5) as pool:
714
715 # Test that we have a new connection after pool not
716 # being used longer than `max_inactive_connection_lifetime`.
717
718 con = pool._holders[0]._con
719
720 self.assertEqual(
721 await pool.execute('SELECT 1::int'),
722 'SELECT 1')
723 self.assertIs(pool._holders[0]._con, con)
724
725 await asyncio.sleep(1)
726 self.assertIs(pool._holders[0]._con, None)
727
728 self.assertEqual(
729 await pool.execute('SELECT 1::int'),
730 'SELECT 1')
731 self.assertIsNot(pool._holders[0]._con, con)
732
733 async def test_pool_max_inactive_time_03(self):
734 async with self.create_pool(

Callers

nothing calls this directly

Calls 2

create_poolMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected