Commit 0f76418
Suspend sys.monitoring events inside sandbox importer
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 #1326
Co-Authored-By: Claude Opus 4.6 <noreply@anthropic.com>1 parent 4e71c2e commit 0f76418
1 file changed
Lines changed: 54 additions & 1 deletion
| Original file line number | Diff line number | Diff line change | |
|---|---|---|---|
| |||
38 | 38 | | |
39 | 39 | | |
40 | 40 | | |
| 41 | + | |
| 42 | + | |
| 43 | + | |
| 44 | + | |
| 45 | + | |
| 46 | + | |
| 47 | + | |
| 48 | + | |
| 49 | + | |
| 50 | + | |
| 51 | + | |
| 52 | + | |
| 53 | + | |
| 54 | + | |
| 55 | + | |
| 56 | + | |
| 57 | + | |
| 58 | + | |
| 59 | + | |
| 60 | + | |
| 61 | + | |
| 62 | + | |
| 63 | + | |
| 64 | + | |
| 65 | + | |
| 66 | + | |
| 67 | + | |
| 68 | + | |
| 69 | + | |
| 70 | + | |
| 71 | + | |
| 72 | + | |
| 73 | + | |
| 74 | + | |
| 75 | + | |
| 76 | + | |
| 77 | + | |
| 78 | + | |
| 79 | + | |
| 80 | + | |
| 81 | + | |
| 82 | + | |
| 83 | + | |
| 84 | + | |
| 85 | + | |
| 86 | + | |
| 87 | + | |
| 88 | + | |
| 89 | + | |
| 90 | + | |
| 91 | + | |
| 92 | + | |
41 | 93 | | |
42 | 94 | | |
43 | 95 | | |
| |||
147 | 199 | | |
148 | 200 | | |
149 | 201 | | |
150 | | - | |
| 202 | + | |
| 203 | + | |
151 | 204 | | |
152 | 205 | | |
153 | 206 | | |
| |||
0 commit comments