Refactor SandboxThread init/reset state setup helpers#196
Merged
seanwevans merged 1 commit intomainfrom Apr 21, 2026
Merged
Conversation
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.
Motivation
__init__andresetshare identical setup behavior.Description
_init_config_wiring(...)helper to centralize configuration/immutable wiring including quotas, merged imports, NUMA/cgroup pointers, and capabilities deserialization._reset_runtime_state()helper to centralize resetting transient counters and runtime fields such as_cpu_time,_mem_peak,_ops,_errors,_latency,_latency_sum,_trace_enabled,_syscall_log,_start_time,_open_files,_network_ops,_output_bytes, and_child_workplus quarantine/termination fields.__init__andresetto call the two helpers so both construction and reuse flows share the same initialization behavior while keeping existing public method signatures and behavior unchanged._next_attach_msg_id/_seen_attach_msg_idsclarifying that the dedup set spans sandbox lifetimes and that attach message IDs are monotonic and intentionally preserved acrossreset()to avoid stale replay collisions.Testing
python -m compileall -q pyisolate/runtime/thread.pywhich completed successfully.python -m pytest -q; the run produced repository-wide failures (106 failed, 101 passed, 1 error) caused by a mismatch in the test stub (_StubBPFManager.load()receiving an unexpectedmodekeyword) and are unrelated to this refactor.Codex Task