- Throw `!ValueError` if the pool `!min_size` is set to 0 (instead of
hanging).
+- Throw `!PoolClosed` calling `~ConnectionPool.wait()` on a closed pool.
Current release
program to terminate in case the environment is not configured
properly, rather than trying to stay up the hardest it can.
"""
+ self._check_open_getconn()
+
with self._lock:
assert not self._pool_full_event
if len(self._pool) >= self._nconns:
self._open()
async def wait(self, timeout: float = 30.0) -> None:
+ self._check_open_getconn()
+
async with self._lock:
assert not self._pool_full_event
if len(self._pool) >= self._nconns:
import pytest
import psycopg
-from psycopg.errors import OperationalError
from psycopg.pq import TransactionStatus
from psycopg._compat import Counter
p.wait(0.0001) # idempotent
+def test_wait_closed(dsn):
+ with pool.ConnectionPool(dsn) as p:
+ pass
+
+ with pytest.raises(pool.PoolClosed):
+ p.wait()
+
+
@pytest.mark.slow
def test_setup_no_timeout(dsn, proxy):
with pytest.raises(pool.PoolTimeout):
assert p._sched_runner is None
assert not p._workers
- with pytest.raises(OperationalError, match="cannot be reused"):
+ with pytest.raises(psycopg.OperationalError, match="cannot be reused"):
p.open()
import pytest
import psycopg
-from psycopg.errors import OperationalError
from psycopg.pq import TransactionStatus
from psycopg._compat import create_task, Counter
await p.wait(0.0001) # idempotent
+async def test_wait_closed(dsn):
+ async with pool.AsyncConnectionPool(dsn) as p:
+ pass
+
+ with pytest.raises(pool.PoolClosed):
+ await p.wait()
+
+
@pytest.mark.slow
async def test_setup_no_timeout(dsn, proxy):
with pytest.raises(pool.PoolTimeout):
await p.close()
assert p._sched_runner is None
- with pytest.raises(OperationalError, match="cannot be reused"):
+ with pytest.raises(psycopg.OperationalError, match="cannot be reused"):
await p.open()