Repository navigation
Conversation
conftest.py's sessions() plays the scenarios side by side from a thread pool, and launch() puts a copy of the game in each scenario's folder. On CI dist/ and /tmp are on different file systems, so os.link fails and shutil.copy writes the copy. If another thread forks while that copy is open for writing, its child holds the descriptor until it runs its own program, and starting the copied game in that time fails with OSError: [Errno 26] Text file busy. That failed all five obstacle tests in CI run 40916137686 (PR #521). launch() now copies the game and starts it under one lock, so no other launch forks while a copy is open (Popen returns only once the child has run the game). The forks of generate()'s tools in other threads are not under the lock, so the start is tried up to five times, a tenth of a second apart, when it fails with ETXTBSY; any other error is raised at once. Checked on Windows, where the scenarios skip without a Linux game: the tests still collect and skip, and a stand-in for Popen showed the retry (two busy failures, then started), giving up after five, other errors raised at once, and eight threads each getting a whole copy. Not yet run on Linux; CI's Linux job runs the scenarios. Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This branch has not been deployed
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.
StageKit's scenarios sometimes fail on CI with
OSError: [Errno 26] Text file busy. In run 40916137686 (PR #521) this failed all fiveobstacletests.Why it happens
conftest.py'ssessions()plays the scenarios side by side from a thread pool.runner.launch()puts a copy of the game in each scenario's folder. On CI,dist/and/tmpare on different file systems, soos.linkfails andshutil.copywrites the copy instead. If another thread forks while that copy is still open for writing, the child keeps the descriptor until it runs its own program. Starting the copied game during that time fails with ETXTBSY.The change (
tools/stagekit/tests/runner.pyonly)launch()now copies the game and starts it under one lock (LAUNCHING). No other launch can fork while a copy is open, andPopenreturns only once the child is running the game.generate()'s tools fork from other threads outside the lock. To cover them, the start is tried up to five times, a tenth of a second apart, when it fails with ETXTBSY. Any other error is raised at once.Checked
Popen: it fails twice as busy, then starts; it gives up after five tries; other errors are raised at once; eight threads launching together each get a whole copy.🤖 Generated with Claude Code