Skip to content

Comments

Suspend sys.monitoring events inside sandbox importer#1327

Open
dsfaccini wants to merge 1 commit intotemporalio:mainfrom
dsfaccini:fix/suspend-sys-monitoring-in-sandbox
Open

Suspend sys.monitoring events inside sandbox importer#1327
dsfaccini wants to merge 1 commit intotemporalio:mainfrom
dsfaccini:fix/suspend-sys-monitoring-in-sandbox

Conversation

@dsfaccini
Copy link

Summary

Test plan

🤖 Generated with Claude Code

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>
@dsfaccini dsfaccini requested a review from a team as a code owner February 11, 2026 23:39
@CLAassistant
Copy link

CLAassistant commented Feb 11, 2026

CLA assistant check
All committers have signed the CLA.

@dsfaccini
Copy link
Author

dsfaccini commented Feb 12, 2026

I don't think the 3.14 test fail is related to this PR. Not sure about the test-latest-deps

Edit: ok I also don't think that error is related to this PR. Any chance you guys can try rerunning the tests?

@tconley1428
Copy link
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.

@dsfaccini
Copy link
Author

agree, just wanted to give you a starting point, lmk if I can help

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

sys.monitoring callbacks (coverage, etc.) cause workflow sandbox hang on Python 3.14

3 participants