Repository navigation
fix(examples): background-process and entrypoint examples no longer race their sandbox - #113
Merged
Merged
Conversation
…lled Process 2 ran for 5 s and was killed after a 2 s sleep plus a few API round trips; when those took over 3 s it had already ended, and the kill failed with 400 "process is not running (status: completed)". The two "sleep 5" processes killed by kill_all_processes had the same race. Let them run for 60 s: every one is killed, so the example takes no longer.
…mand A sandbox is ready once its executor answers; the image's own command (the custom command or entrypoint under test) may not have written its file yet, so the first read could come back empty. Wait up to 10 s for the file before reading it.
bchatelard
marked this pull request as ready for review
November 5, 2026 20:55
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.
Two examples race the sandbox they create and fail intermittently when they run as automated tests:
13_background_processes.pykills a process that may have ended, and19_entrypoint_and_command.pyreads the file its image writes before the image has written it.Why
We run every example as an automated test, many times a day. Over a week of runs:
13_background_processes.pywith400 {"success":false,"error":"process is not running (status: completed)"}. Process 2 runs for 5 s and is killed after a 2 s sleep plus a few API round trips; when those take over 3 s it has already ended. The twosleep 5processes killed bykill_all_processes()have the same race (assert killed_count >= 2).19_entrypoint_and_command.pyhas the race its JavaScript twin fails on (11 times in the same week,Expected 'yes', got ''): a sandbox is ready once its executor answers, and the image's own command (the custom command or entrypoint under test) may not have written its marker file yet.What changed
examples/13_background_processes.py: process 2 and the twosleepprocesses run for 60 s. Every one of them is killed, so the example takes no longer.examples/19_entrypoint_and_command.py: both checks wait up to 10 s (every 0.2 s, in the sandbox's shell) for the file before reading it.The same
19_entrypoint_and_commandchange goes into the JavaScript SDK's example.How it was verified
13_background_processes.pyendskilled, and their sandboxes are deleted.black --checkpasses on both files.