MCPcopy
hub / github.com/psycopg/psycopg / test_active_close

Function test_active_close

tests/pool/test_pool_null.py:334–358  ·  view source on GitHub ↗
(dsn, caplog)

Source from the content-addressed store, hash-verified

332@pytest.mark.crdb_skip("backend pid")
333@pytest.mark.crdb_skip("copy")
334def test_active_close(dsn, caplog):
335 caplog.set_level(logging.WARNING, logger="psycopg.pool")
336 pids = []
337
338 def worker():
339 with p.connection() as conn:
340 pids.append(conn.info.backend_pid)
341 assert conn.info.transaction_status == TransactionStatus.IDLE
342
343 with pool.NullConnectionPool(dsn, max_size=1) as p:
344 conn = p.getconn()
345
346 t = spawn(worker)
347 ensure_waiting(p)
348
349 pids.append(conn.info.backend_pid)
350 conn.pgconn.exec_(b"copy (select * from generate_series(1, 10)) to stdout")
351 assert conn.info.transaction_status == TransactionStatus.ACTIVE
352 p.putconn(conn)
353 gather(t)
354
355 assert pids[0] != pids[1]
356 assert len(caplog.records) == 2
357 assert "ACTIVE" in caplog.records[0].message
358 assert "BAD" in caplog.records[1].message
359
360
361@pytest.mark.crdb_skip("backend pid")

Callers

nothing calls this directly

Calls 6

ensure_waitingFunction · 0.70
spawnFunction · 0.50
gatherFunction · 0.50
getconnMethod · 0.45
exec_Method · 0.45
putconnMethod · 0.45

Tested by

no test coverage detected