MCPcopy
hub / github.com/psycopg/psycopg / test_reconnect_after_grow_failed

Function test_reconnect_after_grow_failed

tests/pool/test_pool_async.py:577–605  ·  view source on GitHub ↗
(proxy)

Source from the content-addressed store, hash-verified

575
576@pytest.mark.slow
577async def test_reconnect_after_grow_failed(proxy):
578 # Retry reconnection after a failed connection attempt has put the pool
579 # in grow mode. See issue #370.
580 proxy.stop()
581
582 ev = AEvent()
583
584 def failed(pool):
585 ev.set()
586
587 async with pool.AsyncConnectionPool(
588 proxy.client_dsn, min_size=4, reconnect_timeout=1.0, reconnect_failed=failed
589 ) as p:
590 assert await ev.wait_timeout(2.0)
591
592 with pytest.raises(pool.PoolTimeout):
593 async with p.connection(timeout=0.5) as conn:
594 pass
595
596 ev.clear()
597 assert await ev.wait_timeout(2.0)
598
599 proxy.start()
600
601 async with p.connection(timeout=2) as conn:
602 await conn.execute("select 1")
603
604 await p.wait(timeout=3.0)
605 assert len(p._pool) == p.min_size == 4
606
607
608@pytest.mark.slow

Callers

nothing calls this directly

Calls 8

wait_timeoutMethod · 0.95
AEventClass · 0.50
stopMethod · 0.45
connectionMethod · 0.45
clearMethod · 0.45
startMethod · 0.45
executeMethod · 0.45
waitMethod · 0.45

Tested by

no test coverage detected