``psycopg_pool`` release notes
==============================
+Future releases
+---------------
+
+psycopg_pool 3.1.2 (unreleased)
+^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
+
+- Fix possible failure to reconnect after losing connection from the server
+ (:ticket:`#370`).
+
+
Current release
---------------
)
with self._lock:
self._nconns -= 1
+ # If we have given up with a growing attempt, allow a new one.
+ if growing and self._growing:
+ self._growing = False
self.reconnect_failed()
else:
attempt.update_delay(now)
)
async with self._lock:
self._nconns -= 1
+ # If we have given up with a growing attempt, allow a new one.
+ if growing and self._growing:
+ self._growing = False
self.reconnect_failed()
else:
attempt.update_delay(now)
assert t1 - t0 < 0.2
+@pytest.mark.slow
+def test_reconnect_retry(proxy):
+ proxy.stop()
+
+ ev = Event()
+
+ def failed(pool):
+ ev.set()
+
+ with pool.ConnectionPool(
+ proxy.client_dsn, reconnect_timeout=1.0, reconnect_failed=failed
+ ) as p:
+ assert ev.wait(timeout=2)
+
+ with pytest.raises(pool.PoolTimeout):
+ with p.connection(timeout=0.5) as conn:
+ pass
+
+ ev.clear()
+ assert ev.wait(timeout=2)
+
+ proxy.start()
+
+ with p.connection(timeout=2) as conn:
+ conn.execute("select 1")
+
+
@pytest.mark.slow
def test_uniform_use(dsn):
with pool.ConnectionPool(dsn, min_size=4) as p:
assert t1 - t0 < 0.2
+@pytest.mark.slow
+async def test_reconnect_retry(proxy):
+ proxy.stop()
+
+ ev = asyncio.Event()
+
+ def failed(pool):
+ ev.set()
+
+ async with pool.AsyncConnectionPool(
+ proxy.client_dsn, reconnect_timeout=1.0, reconnect_failed=failed
+ ) as p:
+ await asyncio.wait_for(ev.wait(), 2.0)
+
+ with pytest.raises(pool.PoolTimeout):
+ async with p.connection(timeout=0.5) as conn:
+ pass
+
+ ev.clear()
+ await asyncio.wait_for(ev.wait(), 2.0)
+
+ proxy.start()
+
+ async with p.connection(timeout=2) as conn:
+ await conn.execute("select 1")
+
+
@pytest.mark.slow
async def test_uniform_use(dsn):
async with pool.AsyncConnectionPool(dsn, min_size=4) as p: