Repository navigation
fix: a shutdown signal on the signal-module fallback wakes an idle loop - #106
Merged
Merged
Conversation
When the loop can't register signal handlers, the fallback handler set the stop event straight from signal.signal. That only queues the event's waiters, so an idle loop slept until its selector timed out, or forever with no timer pending. It now schedules the stop through call_soon_threadsafe, as the Windows handler already did, and both paths share one handler.
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.
Summary
When the loop can't register signal handlers (
add_signal_handlerraises),install_signal_handlersfalls back tosignal.signal. That handler set the stop event directly. Asignal.signalhandler runs outside the loop's callbacks, so setting the event only queues its waiters: an idle loop slept until its selector timed out, or forever with no timer pending.The fallback now schedules the stop with
call_soon_threadsafe, which wakes the loop, as the Windows handler already did. Both paths share one handler, and a second signal still exits at once without going through the loop.The new test sends SIGTERM to the main thread while the loop waits on the event under a 3 s
wait_for. Before the fix the wait ended at 3.0 s, by the timer; now it ends right after the signal.Type of change
Checklist
make checkpasses locally (ruff+mypy)CHANGELOG.mdleft aloneUnit: 801 passed, 14 skipped, coverage 92.5%. Integration: 9 passed.