agents icon indicating copy to clipboard operation
agents copied to clipboard

ConnectionPool.aclose() can leave a connection open when get() is in flight

Open Epsilon006 opened this issue 3 weeks ago • 0 comments

Reproduction

Reproduced on main at 77d67650f5743a197c3ebe9e8908c4980ff8acc2 with Python 3.12 on Windows.

  1. Start ConnectionPool.get() with a connect_cb blocked on an asyncio.Event.
  2. Call aclose() while the handshake is blocked. It returns immediately.
  3. Release the handshake. _connect() sees the changed invalidation generation, closes the first result, and retries. The replacement remains open after shutdown.

An event-driven test also reproduces the early return when get() is blocked draining a queued connection.

Expected behavior

aclose() should account for connections created by acquisitions already in progress before it returns.

Related work

#8244 already proposes a fix. I independently verified that both regressions fail on the base revision and that all 19 connection-pool unit tests pass with its patch.

Epsilon006 avatar Nov 10 '26 13:11 Epsilon006