Skip to content

test: use spawn() in pause/resume tests to avoid thread race#51

Merged
congwang-mk merged 1 commit into
mainfrom
test-pause-resume-spawn
May 18, 2026
Merged

test: use spawn() in pause/resume tests to avoid thread race#51
congwang-mk merged 1 commit into
mainfrom
test-pause-resume-spawn

Conversation

@congwang-mk
Copy link
Copy Markdown
Contributor

Summary

  • The TestPauseResume tests previously launched sb.run(...) in a worker thread and relied on time.sleep(0.15) / time.sleep(0.1) to wait for the sandbox to start before calling pause() / reading pid. On a slow CI runner this flaked with RuntimeError: sandbox is not running, because sandlock_create() hadn't yet returned and self._handle was still None.
  • Rewrite both tests to use sb.spawn(), which is synchronous and guarantees pid is set on return. No worker thread, no polling, no race.
  • Drop the now-unused threading import.

Test plan

  • python3 -m pytest python/tests/test_sandbox.py::TestPauseResume -v (4 passed)
  • python3 -m pytest python/tests/ (247 passed)

Signed-off-by: Cong Wang <cwang@multikernel.io>
@congwang-mk congwang-mk merged commit a4f5901 into main May 18, 2026
8 checks passed
@congwang-mk congwang-mk deleted the test-pause-resume-spawn branch May 18, 2026 03:36
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.

1 participant