Skip to content

Launcher: retry the session replace/read on a Windows sharing violation - #61

Merged
tmori merged 1 commit into
mainfrom
fix/launcher-session-replace-windows
Oct 5, 2026
Merged

tmori merged 1 commit into
mainfrom
fix/launcher-session-replace-windows

Conversation

@tmori

@tmori tmori commented Oct 5, 2026

Copy link
Copy Markdown
Contributor

Fixes #60.

Summary

  • On Windows, os.replace is refused while another process has the destination open. A status poll or Urban Studio reading launcher-session.json at the moment the launcher wrote it made the background worker fail (WinError 5) and terminate the assets it had just started. It happened intermittently in the Urban Studio Windows portable verification (Urban Studio の Windows 持ち運べる版(portable) hakoniwa-urban-mobility#82).
  • write_session's replace and read_session's read now retry PermissionError / WinError 5 and 32 every 50 ms for up to 2 s, on Windows only. POSIX behaviour and other errors are unchanged.

Test

  • New tests/test_launcher_session_windows_sharing.py (5 tests):
    • a refused replace is retried and succeeds
    • it gives up after the timeout without leaving the temporary file
    • a refused read is retried
    • POSIX does not retry
    • other errors are not retried
  • PYTHONPATH=src python -m pytest -q: 121 passed. Without the fix, the 5 new tests fail.

🤖 Generated with Claude Code

…lation (#60)

On Windows os.replace (MoveFileEx) is refused while another process has the
destination open, so a status poll or Urban Studio reading
launcher-session.json at the moment the launcher wrote it made the
background worker fail with WinError 5 and terminate the assets it had just
started (seen intermittently in hakoniwalab/hakoniwa-urban-mobility#82).
write_session's replace and read_session's read now retry PermissionError /
WinError 5 and 32 every 50 ms for up to 2 s, on Windows only; POSIX and other
errors are unchanged.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
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.

Launcher: write_session の os.replace が Windows で間欠的に WinError 5

1 participant