Commit cc1c21b
Clear _closed_event in pool.close's finally so the signalled wakeup event is GC'd alongside the pool's other once-used loop primitives
The pool's close path nulls every other once-used loop-bound
field after use (``_async_conn``, ``_protocol``,
``_connect_lock``, ``_op_lock``, ``_loop_ref``);
``_closed_event`` was the lone holdout. Once
``set()`` runs in the close finally, the at-capacity
wakeup event has no remaining waiters (the pool is
``_closed=True``; new acquirers short-circuit before
parking) — yet the reference stayed pinned for the
lifetime of the pool object, keeping the event's
captured loop reachable through any SA engine
diagnostic accessor / module-level cache that
outlives ``close()``.
``_close_done`` deliberately stays — the second-caller
``if self._closed:`` arm awaits it, and clearing in
that arm would be TOCTOU. Clearing only ``_closed_event``
in the first caller's finally matches the project's
"null every once-used loop-bound field" discipline
without touching the second-caller drain visibility.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent f8a74ac commit cc1c21b
2 files changed
Lines changed: 70 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1432 | 1432 | | |
1433 | 1433 | | |
1434 | 1434 | | |
| 1435 | + | |
| 1436 | + | |
| 1437 | + | |
| 1438 | + | |
| 1439 | + | |
| 1440 | + | |
| 1441 | + | |
| 1442 | + | |
| 1443 | + | |
| 1444 | + | |
| 1445 | + | |
| 1446 | + | |
| 1447 | + | |
1435 | 1448 | | |
1436 | 1449 | | |
1437 | 1450 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
| 1 | + | |
| 2 | + | |
| 3 | + | |
| 4 | + | |
| 5 | + | |
| 6 | + | |
| 7 | + | |
| 8 | + | |
| 9 | + | |
| 10 | + | |
| 11 | + | |
| 12 | + | |
| 13 | + | |
| 14 | + | |
| 15 | + | |
| 16 | + | |
| 17 | + | |
| 18 | + | |
| 19 | + | |
| 20 | + | |
| 21 | + | |
| 22 | + | |
| 23 | + | |
| 24 | + | |
| 25 | + | |
| 26 | + | |
| 27 | + | |
| 28 | + | |
| 29 | + | |
| 30 | + | |
| 31 | + | |
| 32 | + | |
| 33 | + | |
| 34 | + | |
| 35 | + | |
| 36 | + | |
| 37 | + | |
| 38 | + | |
| 39 | + | |
| 40 | + | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
0 commit comments