- 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.run_task(Schedule(self, ShrinkPool(self), self.max_idle))
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:
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):
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):