Conversation
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## latest #3266 +/- ##
=======================================
Coverage 73.29% 73.29%
=======================================
Files 446 446
Lines 108244 108250 +6
Branches 17352 17345 -7
=======================================
+ Hits 79342 79347 +5
- Misses 28626 28627 +1
Partials 276 276 ☔ View full report in Codecov by Harness. 🚀 New features to boost your workflow:
|
Collaborator
|
I think there's a better way to fix this issue. Technically The following should be more reliable than highspy.highs.Highs.wait = lambda self, t: raise KeyboardInterrupt("Simulated user interrupt") # type: ignore[assignment]BTW: Overriding the wait function is a manual and lazy mock; it might be better practice to do the following: # 1. Use a context manager to patch the method safely
with patch.object(highspy.highs.Highs, 'wait') as mock_wait:
# 2. Tell the mock to trigger the signal when called
mock_wait.side_effect = lambda t: raise KeyboardInterrupt("Simulated user interrupt")
h.joinSolve(h.startSolve(), 0)
h.startSolve()
h.joinSolve(None, 0)
with self.assertRaises(SystemExit):
h.startSolve()
h.joinSolve(None, 5)
unittest.main(exit=False) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Description
joinSolve's wait loops (while not result[0]: result = self.wait(0.1)) assumeself.wait()always returns a(bool, HighsStatus | None)tuple.test_user_interruptsreplaceswaitwith a lambda that raisesSIGINTto simulate Ctrl+C during a blocking wait, expecting the resultingKeyboardInterruptto propagate out of that call and get caught by the surroundingexcept KeyboardInterrupt. On some platforms/timings the interrupt doesn't propagate synchronously, so the lambda returnsNoneinstead, and the next loop check crashes withTypeError: 'NoneType' object is not subscriptable— matching the trace in #3265.Guards both wait loops in
joinSolveagainst aNoneresult (result is None or not result[0]) so this keeps polling instead of crashing. Productionwait()never returns anything but a tuple, so this only affects the race.Checklist
latestbranchRelated issue
Closes #3265