Commit 582df33
Reset the asyncio connect lock when the background event loop is torn down
Connection.close() nulled the loop and thread but left _connect_lock
pointing at an asyncio.Lock bound to the loop that had just been closed.
The lazy-create branch in _get_async_connection only rebuilds the lock
when it finds None, so a future path that re-enters after close() would
reuse a primitive attached to a dead loop.
Set _connect_lock back to None alongside _loop/_thread inside the same
critical section so the invariant "asyncio primitive is either None or
attached to the live loop" holds uniformly with the async connection's
lazy-init contract. The public API still guards against use-after-close
via the _closed flag; this is the defensive half of the same contract.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent bd353e3 commit 582df33
2 files changed
+26
-0
lines changed| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
282 | 282 | | |
283 | 283 | | |
284 | 284 | | |
| 285 | + | |
| 286 | + | |
| 287 | + | |
| 288 | + | |
| 289 | + | |
285 | 290 | | |
286 | 291 | | |
287 | 292 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
130 | 130 | | |
131 | 131 | | |
132 | 132 | | |
| 133 | + | |
| 134 | + | |
| 135 | + | |
| 136 | + | |
| 137 | + | |
| 138 | + | |
| 139 | + | |
| 140 | + | |
| 141 | + | |
| 142 | + | |
| 143 | + | |
| 144 | + | |
| 145 | + | |
| 146 | + | |
| 147 | + | |
| 148 | + | |
| 149 | + | |
| 150 | + | |
| 151 | + | |
| 152 | + | |
| 153 | + | |
0 commit comments