Commit 52eaeb6
Gate AsyncConnection ResourceWarning on connected; mark closed in force_close_transport
Two cycle-21 ripple fixes for the AsyncConnection finalizer:
- The "GC'd without await close()" warning fired on never-connected
instances (``conn = AsyncConnection(...); del conn``, common in
early-error and test-fixture flows). Add a companion
``_connected_flag`` that flips True only after
``_ensure_connection`` successfully builds the underlying client
connection; the finalizer skips the warning until it's set.
- ``force_close_transport`` (used by SA's ``terminate()`` outside-
greenlet preflight, post-await RuntimeError catches, and direct
user calls) reaped the writer transport but did not set
``closed_flag``. A subsequent GC sweep then emitted the warning
even though the transport had been explicitly closed. Set the
flag at the top of the method so any path through it counts as
explicit cleanup.
Test fixture that bypasses ``__init__`` via ``__new__`` updated to
inject the new flag.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent c28bbc8 commit 52eaeb6
2 files changed
Lines changed: 48 additions & 3 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
40 | 40 | | |
41 | 41 | | |
42 | 42 | | |
43 | | - | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
44 | 46 | | |
45 | 47 | | |
46 | 48 | | |
| |||
53 | 55 | | |
54 | 56 | | |
55 | 57 | | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
56 | 75 | | |
57 | 76 | | |
58 | 77 | | |
59 | | - | |
| 78 | + | |
60 | 79 | | |
61 | 80 | | |
62 | 81 | | |
| |||
224 | 243 | | |
225 | 244 | | |
226 | 245 | | |
227 | | - | |
| 246 | + | |
| 247 | + | |
| 248 | + | |
| 249 | + | |
| 250 | + | |
| 251 | + | |
| 252 | + | |
| 253 | + | |
| 254 | + | |
| 255 | + | |
| 256 | + | |
| 257 | + | |
| 258 | + | |
| 259 | + | |
228 | 260 | | |
229 | 261 | | |
230 | 262 | | |
| |||
339 | 371 | | |
340 | 372 | | |
341 | 373 | | |
| 374 | + | |
| 375 | + | |
| 376 | + | |
| 377 | + | |
342 | 378 | | |
343 | 379 | | |
344 | 380 | | |
| |||
546 | 582 | | |
547 | 583 | | |
548 | 584 | | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
| 591 | + | |
| 592 | + | |
549 | 593 | | |
550 | 594 | | |
551 | 595 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
39 | 39 | | |
40 | 40 | | |
41 | 41 | | |
| 42 | + | |
42 | 43 | | |
43 | 44 | | |
44 | 45 | | |
| |||
0 commit comments