Repository navigation
Fix cold shutdown for the gevent and threads pools - #11065
Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #11065 +/- ##
==========================================
+ Coverage 91.49% 91.53% +0.03%
==========================================
Files 153 153
Lines 22176 22208 +32
Branches 2772 2783 +11
==========================================
+ Hits 20291 20329 +38
+ Misses 1584 1580 -4
+ Partials 301 299 -2
Flags with carried forward coverage won't be shown. Click here to find out more. ☔ View full report in Codecov by Harness. |
auvipy
left a comment
There was a problem hiding this comment.
unit test coverage should be improved
|
yeah the breaking part should be handled by the other PR. in this PR we should focus on fix that do not change public API surface or its signatures |
|
This fixes the exit, and the duplicate on the threads pool with SIGINT twice. One thing is the same before and after, and I don't think it should hold this PR: on gevent a cold shutdown acknowledges the message of a late-ack task it interrupts, so the task is lost. That is a regression in 5.5.0 (#9083 and #9213). I'll open an issue for it.
Each cell is 3 of 3 runs. Details
|
|
thank you all! |
Description
Fixes #11059. Refs #10490.
Run gevent cold shutdown in a greenlet so the soft shutdown wait and broker calls can yield. Keep the initial shutdown responsible for signaling teardown, including when another shutdown signal arrives.
For threads, schedule cold shutdown on the consumer loop so the signal handler cannot reenter the executor with its lock held. Shutdown cancels queued futures and drains running tasks. This avoids the unsupported termination call and keeps running tasks from being reported as cancelled. Running tasks can still outlast the soft shutdown timeout. Revoking a running thread with terminate=True is outside this change. PR #10491 proposes a separate approach to that part of #10490.
@auvipy this follows your note to cover both related issues in a single PR. Would appreciate a review when you get a chance.
Validation
268 focused unit tests passed, 4 skipped, plus 40 subtests. Real Linux workers using the memory broker exited successfully after gevent SIGQUIT, remapped SIGTERM, and threads SIGQUIT. The unmodified worker reproduced both reported exceptions.