Commit 05b09ca
committed
feat: graceful SIGTERM/SIGINT drain of workers (finish in-flight task before exit)
Worker loops ran `while True` and ignored the shutdown flag, and the threads are
daemons — so on SIGTERM the process exited and killed them mid-task, orphaning the
in-flight task (and losing its result if the task handler uploaded synchronously).
Worker loops now run `while not self._shutdown_event.is_set()` and blpop with a 5s
timeout so shutdown is noticed promptly. New ModelQ.shutdown() sets the event and
joins the worker threads (up to a timeout), and the CLI calls it on SIGTERM/SIGINT
so an in-flight task — and its upload — completes before the process exits.1 parent 5199a36 commit 05b09ca
3 files changed
Lines changed: 26 additions & 4 deletions
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
152 | 152 | | |
153 | 153 | | |
154 | 154 | | |
| 155 | + | |
| 156 | + | |
| 157 | + | |
155 | 158 | | |
156 | 159 | | |
157 | 160 | | |
| |||
662 | 665 | | |
663 | 666 | | |
664 | 667 | | |
| 668 | + | |
| 669 | + | |
| 670 | + | |
| 671 | + | |
| 672 | + | |
| 673 | + | |
| 674 | + | |
| 675 | + | |
| 676 | + | |
| 677 | + | |
| 678 | + | |
| 679 | + | |
| 680 | + | |
| 681 | + | |
| 682 | + | |
665 | 683 | | |
666 | 684 | | |
667 | 685 | | |
| |||
703 | 721 | | |
704 | 722 | | |
705 | 723 | | |
706 | | - | |
| 724 | + | |
707 | 725 | | |
708 | 726 | | |
709 | 727 | | |
| |||
712 | 730 | | |
713 | 731 | | |
714 | 732 | | |
715 | | - | |
| 733 | + | |
716 | 734 | | |
717 | 735 | | |
718 | 736 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
93 | 93 | | |
94 | 94 | | |
95 | 95 | | |
96 | | - | |
| 96 | + | |
| 97 | + | |
| 98 | + | |
| 99 | + | |
| 100 | + | |
97 | 101 | | |
98 | 102 | | |
99 | 103 | | |
| |||
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
1 | 1 | | |
2 | 2 | | |
3 | | - | |
| 3 | + | |
4 | 4 | | |
5 | 5 | | |
6 | 6 | | |
| |||
0 commit comments