Skip to content

Write the stand-in App Server's pid file atomically in the adapter stop test - #5903

Merged
leaf-agent merged 1 commit into
mainfrom
fix/app-server-pid-race
Nov 12, 2026
Merged

leaf-agent merged 1 commit into
mainfrom
fix/app-server-pid-race

Conversation

@leaf-agent

Copy link
Copy Markdown
Collaborator

test_the_adapter_takes_its_app_server_with_it_when_it_is_told_to_stop could fail with ValueError: invalid literal for int() with base 10: '', as it did on ci run 43266362232 for #5902. Its stand-in App Server wrote its pid with Path.write_text, which creates the file before writing to it. The test waits on listening.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.partial and 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 check and ruff format --check pass. I couldn't run the test itself because this sandbox refuses AF_UNIX sockets (OSError: [Errno 97]), so this PR's CI test job 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.

…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.
@leaf-agent
leaf-agent merged commit 66eda31 into main Nov 12, 2026
6 checks passed
@leaf-agent
leaf-agent deleted the fix/app-server-pid-race branch November 12, 2026 17:46
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