From d672a862511b1bf00c310060f6297f4de793403f Mon Sep 17 00:00:00 2001 From: Aditya kumar singh <143548997+Adityakk9031@users.noreply.github.com> Date: Sun, 19 Jul 2026 00:47:20 +0530 Subject: [PATCH] fix: handle WinError 87 in process_is_alive on Windows ### Description This PR fixes a critical crash that occurs on Windows when Yoke attempts to clean up stale temporary deployments. When `os.kill(pid, 0)` is used to check if a process is alive on Windows, checking a non-existent PID raises `OSError: [WinError 87] The parameter is incorrect` instead of `ProcessLookupError` as it does on Unix. Because this exception was previously uncaught, `deploy_runtime` would crash entirely if there were stale deployment directories in the temp folder left over from dead processes. This change catches `OSError` in `process_is_alive`, correctly treating the process as dead on Windows and allowing the garbage collection of the temporary directories to proceed smoothly. ### Testing - [x] Verified that `pytest tests/test_runtime_deployments.py::test_runtime_deployment_reclaims_only_dead_owned_directories` now passes successfully on Windows without raising `WinError 87`. ### Related Issues Fixes #[Insert Issue Number Here] --- src/yoke/providers/runtime_deployment.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/src/yoke/providers/runtime_deployment.py b/src/yoke/providers/runtime_deployment.py index c97285e..f4c1522 100644 --- a/src/yoke/providers/runtime_deployment.py +++ b/src/yoke/providers/runtime_deployment.py @@ -126,6 +126,8 @@ def process_is_alive(pid: int) -> bool: return False except PermissionError: return True + except OSError: + return False return True