Skip to content

fix: handle WinError 87 in process_is_alive on Windows#3

Open
Adityakk9031 wants to merge 1 commit into
AlmanacCode:mainfrom
Adityakk9031:#2
Open

fix: handle WinError 87 in process_is_alive on Windows#3
Adityakk9031 wants to merge 1 commit into
AlmanacCode:mainfrom
Adityakk9031:#2

Conversation

@Adityakk9031

Copy link
Copy Markdown

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

  • 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 #2

### 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]
@Adityakk9031

Copy link
Copy Markdown
Author

@divitsheth have a look

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.

Bug: process_is_alive crashes Yoke runtime deployments on Windows (OSError: [WinError 87])

1 participant