Commit 12ee7aa
Register find_leader done-callback before slot insertion
The single-flight body in find_leader previously inserted the task
into the shared slot map, then registered the done-callback. A
signal-driven interrupt (KeyboardInterrupt / SystemExit raised by
a signal handler at any bytecode boundary between the two
statements) could leave the slot pointing at a task whose
completion is never observed by _clear_slot — surfacing as a
"Task exception was never retrieved" warning at GC time.
Reorder so add_done_callback runs before the slot insertion. The
callback is safe on a not-yet-started task; _clear_slot's
"only delete if it still points at us" guard already handles the
case where the slot was never set. The race window is closed by
construction.
Co-Authored-By: Claude Opus 4.7 (1M context) <noreply@anthropic.com>1 parent 0cfb00e commit 12ee7aa
2 files changed
Lines changed: 47 additions & 1 deletion
File tree
- src/dqliteclient
- tests
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
205 | 205 | | |
206 | 206 | | |
207 | 207 | | |
208 | | - | |
209 | 208 | | |
210 | 209 | | |
211 | 210 | | |
| |||
228 | 227 | | |
229 | 228 | | |
230 | 229 | | |
| 230 | + | |
| 231 | + | |
| 232 | + | |
| 233 | + | |
| 234 | + | |
| 235 | + | |
| 236 | + | |
| 237 | + | |
| 238 | + | |
| 239 | + | |
231 | 240 | | |
| 241 | + | |
232 | 242 | | |
233 | 243 | | |
234 | 244 | | |
| |||
Lines changed: 36 additions & 0 deletions
| 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 | + | |
0 commit comments