Skip to content

Launcher: wait for the fail-stop cleanup before ending; reason = trigger - #68

Merged
tmori merged 1 commit into
mainfrom
fix/fail-stop-cleanup-before-exit
Oct 16, 2026
Merged

tmori merged 1 commit into
mainfrom
fix/fail-stop-cleanup-before-exit

Conversation

@tmori

@tmori tmori commented Oct 16, 2026

Copy link
Copy Markdown
Contributor

Found by the Windows test run for toppers/hakoniwa-core-cpp#62 (test 4: taskkill of the Urban car plant during a run).

Cleanup cut short. _fail_stop sets FAILED before running the cleanup, so nothing else starts. The background worker's serve_until_terminated leaves its loop on FAILED, and _run_background_worker returns. That ended the process while the cleanup was still running in the daemon watch thread. On Windows, where process stops are slow, the pacer and the scenario link (4 Python processes) kept running, failure_report.cleanup was null, and the Launcher process was gone. Every path that ends on FAILED now waits for the cleanup (LauncherService.wait_for_failure_cleanup, up to 60 s). These paths are the background worker's serve_until_terminated and its exception path, plus the foreground immediate and activate-only modes.

Misleading reason. The failure report started from the last periodic health report. While the master runs, that report is often UNKNOWN "OS file lock is busy", so an asset exit was reported as fail-stop: OS file lock is busy. Only the health-check triggers (startup_runtime_integrity_abort, runtime_integrity_abort) now take the health report as their status and reason. For other triggers, the reason names the trigger (for example asset urban-car-fleet-plant exited unexpectedly (exit code 1)), and the last check is kept as last_health_check.

Tests: 2 new tests in tests/test_launcher_fail_stop.py. The worker test fails without the fix. With the fix, PYTHONPATH=src pytest tests gives 136 passed.

🤖 Generated with Claude Code

…ort the trigger as the reason

_fail_stop sets FAILED before the cleanup (so nothing else starts), and the
background worker ends on FAILED: its end stopped the cleanup, which runs in the
daemon watch thread, halfway. On Windows (slow process stops) an asset killed
during a run left the pacer and the scenario link running, with no cleanup in
the failure report. Every path that ends on FAILED now waits for the cleanup
(up to 60 s).

A fail-stop not found by the health check (an asset exit, a watch exception) no
longer takes the last periodic check as its status and reason (often UNKNOWN
'OS file lock is busy' while the master runs): the reason names the trigger,
the check is kept as last_health_check.

Found by the Windows hakoniwa-core-cpp#62 test run (test 4).

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@tmori
tmori merged commit 7d4775d into main Oct 16, 2026
8 checks passed
@tmori
tmori deleted the fix/fail-stop-cleanup-before-exit branch October 16, 2026 11:07
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