Repository navigation
Write the stand-in App Server's pid file atomically in the adapter stop test - #5903
Merged
Merged
Conversation
…op test
test_the_adapter_takes_its_app_server_with_it_when_it_is_told_to_stop polls
for the pid file with is_file() and then parses it. Path.write_text creates
the file before it writes the pid, so the poll could read it empty and fail
with int(''), as it did in ci run 43266362232 on #5902. The stand-in now
writes to a sibling file and renames it into place, so the file appears only
complete. No behavior the test protects changes.
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.
test_the_adapter_takes_its_app_server_with_it_when_it_is_told_to_stopcould fail withValueError: invalid literal for int() with base 10: '', as it did on ci run 43266362232 for #5902. Its stand-in App Server wrote its pid withPath.write_text, which creates the file before writing to it. The test waits onlistening.is_file()and then parses the file, so a poll that lands between those two steps reads an empty string.The stand-in now writes the pid to
app-server.pid.partialand renames it into place. A rename is atomic on one filesystem, so the file only ever appears with the pid in it. The test still asserts the same things.Verification:
ruff checkandruff format --checkpass. I couldn't run the test itself because this sandbox refusesAF_UNIXsockets (OSError: [Errno 97]), so this PR's CItestjob is the first run of the changed test. It's a timing race, so no test here fails deterministically before the change; the failing CI run linked above is the evidence from before the fix.