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

Method test_pool_max_inactive_time_03

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

Source from the content-addressed store, hash-verified

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(
735 database='postgres', init_size=1, min_size=0, max_size=1,
736 max_inactive_connection_lifetime=1) as pool:
737
738 # Test that we start counting inactive time *after*
739 # the connection is being released back to the pool.
740
741 con = pool._holders[0]._con
742
743 await pool.execute('SELECT pg_sleep(0.5)')
744 await asyncio.sleep(0.6)
745
746 self.assertIs(pool._holders[0]._con, con)
747
748 self.assertEqual(
749 await pool.execute('SELECT 1::int'),
750 'SELECT 1')
751 self.assertIs(pool._holders[0]._con, con)
752
753 async def test_pool_max_inactive_time_04(self):
754 # Chaos test for max_inactive_connection_lifetime.

Callers

nothing calls this directly

Calls 2

create_poolMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected