-
Notifications
You must be signed in to change notification settings - Fork 4
Fix race conditions #57
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This PR addresses race conditions in the hapless process management system by handling scenarios where processes finish too quickly and improving cleanup reliability.
- Add exception handling for process environment retrieval when the process terminates quickly
- Implement waiting for return code file creation before cleanup to prevent premature removal
- Improve error handling in wrapper to exit with proper status codes
Reviewed Changes
Copilot reviewed 5 out of 5 changed files in this pull request and generated 2 comments.
Show a summary per file
| File | Description |
|---|---|
| tools/upload_artifacts.py | Complete file removal (unrelated to race condition fixes) |
| hapless/wrapper.py | Add proper error logging and exit handling for unbound hap status |
| hapless/main.py | Add ignore_errors flag to rmtree and wait for return code file before cleanup |
| hapless/hap.py | Add exception handling for process environment retrieval race condition |
| .github/workflows/tests.yml | Add warnings-as-errors flag to pytest configuration |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
| while hap_killed.active: | ||
| hap_killed = self.get_hap(hid) | ||
|
|
||
| rc_exists = wait_created(hap_killed._rc_file, timeout=1) |
Copilot
AI
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The function wait_created is called but not imported or defined in the visible context. This will result in a NameError at runtime.
| f.write(f"Hap {hap} has to be unbound, found instead {hap.status}\n") | ||
| return | ||
| f.write(message) | ||
| logger.error(message) |
Copilot
AI
Aug 13, 2025
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
[nitpick] The message variable is created just to be used in two places. Consider inlining the message or extracting it to a constant if this pattern is used elsewhere in the codebase.
Description