Suspend sys.monitoring events inside sandbox importer#1327
Open
dsfaccini wants to merge 1 commit intotemporalio:mainfrom
Open
Suspend sys.monitoring events inside sandbox importer#1327dsfaccini wants to merge 1 commit intotemporalio:mainfrom
dsfaccini wants to merge 1 commit intotemporalio:mainfrom
Conversation
sys.monitoring callbacks (PEP 669) are global and fire on all threads. When tools like coverage register branch callbacks, they can trigger lazy imports inside the sandbox on Python 3.14+, causing RestrictedWorkflowAccessError and hanging the workflow. Suspend all sys.monitoring events while the sandbox importer is active and restore them on exit. Uses reference counting so concurrent sandbox activations from multiple worker threads correctly share state. Fixes temporalio#1326 Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>
Author
|
I don't think the 3.14 test fail is related to this PR. Not sure about the Edit: ok I also don't think that error is related to this PR. Any chance you guys can try rerunning the tests? |
Contributor
|
The tests have some flakes, don't worry about that. We still need to determine if this is how we would like to address this, and it will definitely need tests if we do decide to go with it. |
Author
|
agree, just wanted to give you a starting point, lmk if I can help |
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
sys.monitoringevents while the sandbox importer is active, preventing global monitoring callbacks (e.g. coverage's branch tracer) from triggering lazy imports inside the sandboxTest plan
coverage run --branchon Python 3.14 — should complete instead of hanging🤖 Generated with Claude Code