MCPcopy
hub / github.com/psycopg/psycopg / test_reset_broken

Function test_reset_broken

tests/pool/test_pool_null_async.py:228–254  ·  view source on GitHub ↗
(dsn, caplog)

Source from the content-addressed store, hash-verified

226
227@pytest.mark.crdb_skip("backend pid")
228async def test_reset_broken(dsn, caplog):
229 caplog.set_level(logging.WARNING, logger="psycopg.pool")
230
231 async def reset(conn):
232 async with conn.transaction():
233 await conn.execute("WAT")
234
235 pids = []
236
237 async def worker():
238 async with p.connection() as conn:
239 await conn.execute("select 1")
240 pids.append(conn.info.backend_pid)
241
242 async with pool.AsyncNullConnectionPool(dsn, max_size=1, reset=reset) as p:
243 async with p.connection() as conn:
244 t = spawn(worker)
245 await ensure_waiting(p)
246
247 await conn.execute("select 1")
248 pids.append(conn.info.backend_pid)
249
250 await gather(t)
251
252 assert pids[0] != pids[1]
253 assert caplog.records
254 assert "WAT" in caplog.records[0].message
255
256
257@pytest.mark.slow

Callers

nothing calls this directly

Calls 5

ensure_waitingFunction · 0.70
spawnFunction · 0.50
gatherFunction · 0.50
connectionMethod · 0.45
executeMethod · 0.45

Tested by

no test coverage detected