Thanks to visit codestin.com
Credit goes to github.com

Skip to content

Conversation

@bmwant
Copy link
Owner

@bmwant bmwant commented Aug 13, 2025

Description

  • Fix getting environment when process finishes too quickly
  • Fix restarting when hap wrapper writes return code after state directory is cleaned up

Copy link

Copilot AI left a 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)
Copy link

Copilot AI Aug 13, 2025

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.

Copilot uses AI. Check for mistakes.
f.write(f"Hap {hap} has to be unbound, found instead {hap.status}\n")
return
f.write(message)
logger.error(message)
Copy link

Copilot AI Aug 13, 2025

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.

Copilot uses AI. Check for mistakes.
@bmwant bmwant merged commit a482f54 into main Aug 13, 2025
8 checks passed
@bmwant bmwant deleted the fix-race-conditions branch August 13, 2025 10:21
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.

2 participants