fix: handle WinError 87 in process_is_alive on Windows#3
Open
Adityakk9031 wants to merge 1 commit into
Open
Conversation
### 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]
Author
|
@divitsheth have a look |
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.
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 raisesOSError: [WinError 87] The parameter is incorrectinstead ofProcessLookupErroras it does on Unix. Because this exception was previously uncaught,deploy_runtimewould crash entirely if there were stale deployment directories in the temp folder left over from dead processes.This change catches
OSErrorinprocess_is_alive, correctly treating the process as dead on Windows and allowing the garbage collection of the temporary directories to proceed smoothly.Testing
pytest tests/test_runtime_deployments.py::test_runtime_deployment_reclaims_only_dead_owned_directoriesnow passes successfully on Windows without raisingWinError 87.Related Issues
Fixes #2