-
Notifications
You must be signed in to change notification settings - Fork 2
Fix race condition in InThreadIMDServer by auto-binding to free port #94
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
Codecov Report✅ All modified and coverable lines are covered by tests. 🚀 New features to boost your workflow:
|
Co-authored-by: ljwoods2 <[email protected]>
InThreadIMDServer should bind a free port and return it rather than using get_free_port|
@ljwoods2 please review your copilot PRs. Once you approve I'll have a look. |
ljwoods2
left a comment
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.
Remove unused get_free_port method
The |
|
@copilot keep it as-is, good catch |
orbeckst
left a comment
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.
LGTM, thanks!
…owing PR #94 changes Co-authored-by: ljwoods2 <[email protected]>
Problem
The
InThreadIMDServertest utility had a race condition where tests would callget_free_port()to obtain a free port, but between that call and the server binding to it, another process could claim the port, causing intermittent test failures.This race condition was impacting the core MDAnalysis codebase since PR MDAnalysis/mdanalysis#4923 uses the test server.
Solution
Modified
InThreadIMDServerto bind to port 0 (which automatically assigns a free port) instead of taking a port parameter, eliminating the race condition entirely.Changes Made
Modified
InThreadIMDServer.handshake_sequence():handshake_sequence(host, port, first_frame=True)tohandshake_sequence(host, first_frame=True)_bound_portinstance variableAdded
portproperty:server.portNonebefore binding, port number after bindingUpdated test fixtures:
server.portinstead of passing a port parameterget_free_portimport from unit testsget_free_portfunction for integration tests that still need itExample Usage
Verification
Fixes #81.
💬 Share your feedback on Copilot coding agent for the chance to win a $200 gift card! Click here to start the survey.