Repository navigation
fix(worker): don't crash when stopping an exited worker on Windows - #718
Open
Wayfarer545 wants to merge 1 commit into
Open
Wayfarer545 wants to merge 1 commit into
Wayfarer545 wants to merge 1 commit into
Conversation
This branch has not been deployed
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
On Windows, Ctrl+C can crash the main process with
PermissionError: [WinError 5] Access is deniedand exit code 1.The console delivers Ctrl+C to the workers too, so an idle worker has often exited by the time
_shutdown_workerscallsos.kill. On Windowsos.killmeansTerminateProcess, which fails this way for a process that has already exited. CPython handles the same case inPopen.terminate.This change treats
PermissionErrorlike the existingProcessLookupErrorbranch.Related to #422: same traceback, but the cause here isn't user permissions.
If several workers are running, the exception used to abort the loop, so workers after the exited one were left to finish their shutdown. Now they get
os.killtoo, as they already do when no worker has exited. On Windows that terminates them right away. That existing behavior is not changed here.Tested on Windows 11, Python 3.13, with a real Ctrl+C in a new console (idle broker with 1 and 2 workers,
ZeroMQBrokerwithtornado):The new test fails on Windows without the fix and passes with it on 3.10, 3.13 and 3.14. On Linux it passes either way, through the
ProcessLookupErrorbranch, so only the Windows CI job catches a regression.