fix: skip SIGINT handler registration outside the main thread - #1710
Merged
SAKURA-CAT merged 2 commits intoJul 24, 2026
Conversation
Replace the `_sigint_handler_registered` boolean with a single `_is_main_thread` check computed at init time. This avoids a superfluous field and makes it impossible for the restore logic to get out of sync with the registration decision. Also clean up test fixtures: use setup/teardown methods for global state restoration and rename the final test to reflect the new invariant.
Member
|
Thx! |
SAKURA-CAT
approved these changes
Jul 24, 2026
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.
Description
signal.signal(signal.SIGINT, ...)can only be called from the main thread. In non-main-thread contexts such as Ray actors, registering the handler duringRun.__init__raisesValueErrorand crashes initialization.Closes: #1708
This PR:
Run.__init__is called on the main thread._sigint_handler_registered.finish()if it was previously registered.UV_INDEX_URL=https://pypi.tuna.tsinghua.edu.cn/simple uv run pytest tests/unit -q 1561 passed, 21 skipped, 8 warnings in 59.17s