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

Method test_pool_04

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

Source from the content-addressed store, hash-verified

100 del con
101
102 async def test_pool_04(self):
103 pool = await self.create_pool(database='postgres',
104 init_size=1, min_size=1, max_size=1)
105
106 con = await pool.acquire(timeout=POOL_NOMINAL_TIMEOUT)
107
108 # Manual termination of pool connections releases the
109 # pool item immediately.
110 con.terminate()
111 self.assertIsNone(pool._holders[0]._con)
112 self.assertIsNone(pool._holders[0]._in_use)
113
114 con = await pool.acquire(timeout=POOL_NOMINAL_TIMEOUT)
115 self.assertEqual(await con.fetchval('SELECT 1'), 1)
116
117 await con.close()
118 self.assertIsNone(pool._holders[0]._con)
119 self.assertIsNone(pool._holders[0]._in_use)
120 # Calling release should not hurt.
121 await pool.release(con)
122
123 pool.terminate()
124
125 async def test_pool_05(self):
126 for n in {1, 3, 5, 10, 20, 100}:

Callers

nothing calls this directly

Calls 6

create_poolMethod · 0.45
acquireMethod · 0.45
terminateMethod · 0.45
fetchvalMethod · 0.45
closeMethod · 0.45
releaseMethod · 0.45

Tested by

no test coverage detected