Skip to content
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

Prevent race condition in genpy via named mutex #2118

Open
wants to merge 2 commits into
base: main
Choose a base branch
from

Conversation

Chronial
Copy link

@Chronial Chronial commented Sep 7, 2023

As described in its comment, #1601 did not fully fix the problems of #1600. It massively reduced the problem and the duration of the race condition, but did not remove it.

Opening many instances of the same com server in parallel can still cause exceptions in finish_writer. This is caused by two things:

  • Another python instance might have reached the os.rename between our os.unlink and our os.rename, causing our rename to fail. This could be fixed by simply replacing the os.rename with os.replace, but then:
  • Another python instance might currently be parsing the .py we want to override when we call os.replace, causing the replace to fail.

The only proper solution for this issue I could think of is to use a named mutex to force mutual exclusion between all the operations that might interfere with each other. This solution is implemented in this PR.

@Avasam
Copy link
Collaborator

Avasam commented May 28, 2024

@Chronial your PR currently has conflicts

@Chronial
Copy link
Author

👍 resolved

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