pg.ddx.io psycopg/psycopg GitHub issues and pull requests
help / color / mirror / Atom feed[psycopg/psycopg] issue #1475: pool.wait() raises AssertionError after a previous wait() was cancelled
3+ messages / 3 participants
[nested] [flat]
* [psycopg/psycopg] issue #1475: pool.wait() raises AssertionError after a previous wait() was cancelled
@ 2026-11-03 12:53 "ericdelorefice (@ericdelorefice)" <noreply+ericdelorefice@github.com>
0 siblings, 0 replies; 3+ messages in thread
From: ericdelorefice (@ericdelorefice) @ 2026-11-03 12:53 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
If the task running `pool.wait()` (or `open(wait=True)`) is cancelled, for example by a task group or a shutdown, `_pool_full_event` is never reset, because the reset after `wait_timeout()` only runs on a normal return. From then on every `wait()` and `open(wait=True)` fails on `assert not self._pool_full_event`, even once the pool is full, since the assert comes before the "already full" check. `connection()` keeps working.
This is not the concurrent case from #515: the calls are sequential, and the first `wait()` has already ended by cancellation before the next one starts.
```python
import asyncio
import psycopg_pool
async def slow_configure(conn):
await asyncio.sleep(0.5) # pool takes a while to fill
async def main():
async with psycopg_pool.AsyncConnectionPool(
"", min_size=2, configure=slow_configure
) as pool:
t = asyncio.create_task(pool.wait())
await asyncio.sleep(0.1)
t.cancel()
try:
await t
except asyncio.CancelledError:
pass
await asyncio.sleep(2) # the pool is full by now
await pool.wait() # AssertionError
asyncio.run(main())
```
```
File ".../psycopg_pool/pool_async.py", line 191, in wait
assert not self._pool_full_event
AssertionError
```
Without the cancel the second `wait()` returns normally. psycopg-pool 3.3.3, psycopg 3.3.6, Python 3.15, PostgreSQL 18; same code on master. pool.py and both null pools have the same code (in the sync pool, a caught Ctrl-C during `wait()` does it).
The reset should happen in a finally. Happy to send a PR.
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [psycopg/psycopg] issue #1475: pool.wait() raises AssertionError after a previous wait() was cancelled
@ 2026-11-10 18:28 "arapuandrei (@arapuandrei)" <noreply+arapuandrei@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: arapuandrei (@arapuandrei) @ 2026-11-10 18:28 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
Hey @dvarrazzo , I saw you mentioned you'd handle this issue internally, but I thought I'd give it a try anyway. I added a fix and some regression tests, and all 57 CI checks passed.
If you haven't gotten around to fixing it yet, maybe you could take a look at this PR. Happy to make any changes if needed. Thanks!
^ permalink raw [nested|flat] 3+ messages in thread
* Re: [psycopg/psycopg] issue #1475: pool.wait() raises AssertionError after a previous wait() was cancelled
@ 2026-11-11 16:57 "dvarrazzo (@dvarrazzo)" <noreply+dvarrazzo@github.com>
1 sibling, 0 replies; 3+ messages in thread
From: dvarrazzo (@dvarrazzo) @ 2026-11-11 16:57 UTC (permalink / raw)
To: psycopg/psycopg <noreply+psycopg-psycopg@github.com>
@arapuandrei yes, will do. I'm focusing on releasing 3.3.9, which should happen between today and tomorrow, and then I'll move to fix the pool, which has accumulated a handful of bug fixes 🙂
^ permalink raw [nested|flat] 3+ messages in thread
end of thread, other threads:[~2026-11-11 16:57 UTC | newest]
Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 12:53 [psycopg/psycopg] issue #1475: pool.wait() raises AssertionError after a previous wait() was cancelled "ericdelorefice (@ericdelorefice)" <noreply+ericdelorefice@github.com>
2026-11-10 18:28 ` "arapuandrei (@arapuandrei)" <noreply+arapuandrei@github.com>
2026-11-11 16:57 ` "dvarrazzo (@dvarrazzo)" <noreply+dvarrazzo@github.com>
This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox