Commit c51d824
parallel: fix Ctrl-C hang once the worker pool is running
A terminal Ctrl-C sends SIGINT to the whole foreground process group, so
each ProcessPoolExecutor worker gets it too. A KeyboardInterrupt raised
inside a worker's compiled demod (or while it holds a multiprocessing
queue lock) wedged the worker in futex_wait; the parent, after writing
the .tbc.db cleanly, then hung in do_wait joining that worker at exit.
Two changes:
- _demod_worker_init sets SIGINT to SIG_IGN, so only the main process
handles the interrupt and workers never die mid-task holding a lock.
- DemodBlockCache.close() terminate()s the pool's worker processes before
shutdown(wait=False), so the interpreter's atexit join doesn't block on
a worker still in a long demod. Their results are no longer needed.
Reproduced with `ld-decode testdata/ntsc/ve-monitor.ldf mon -t 8` plus a
group SIGINT ~15-24s in: before, the parent hung indefinitely (do_wait on
futex-stuck workers); after, it exits ~0.5s post-INT at every interrupt
point tried (11/13/15/18/20/24s) with an integrity-ok .tbc.db. A normal
uninterrupted -t8 decode still completes and exits 0.
Co-Authored-By: Claude Opus 4.8 (1M context) <noreply@anthropic.com>1 parent a23b2a3 commit c51d824
1 file changed
Lines changed: 18 additions & 0 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
30 | 30 | | |
31 | 31 | | |
32 | 32 | | |
| 33 | + | |
33 | 34 | | |
34 | 35 | | |
35 | 36 | | |
| |||
47 | 48 | | |
48 | 49 | | |
49 | 50 | | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
50 | 59 | | |
51 | 60 | | |
52 | 61 | | |
| |||
570 | 579 | | |
571 | 580 | | |
572 | 581 | | |
| 582 | + | |
| 583 | + | |
| 584 | + | |
| 585 | + | |
| 586 | + | |
| 587 | + | |
| 588 | + | |
| 589 | + | |
| 590 | + | |
573 | 591 | | |
574 | 592 | | |
575 | 593 | | |
| |||
0 commit comments