| 332 | @pytest.mark.crdb_skip("backend pid") |
| 333 | @pytest.mark.crdb_skip("copy") |
| 334 | def 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") |