emcy: Fix maximum timeout logic errors in EmcyConsumer.wait()#668
Draft
acolomb wants to merge 1 commit into
Draft
emcy: Fix maximum timeout logic errors in EmcyConsumer.wait()#668acolomb wants to merge 1 commit into
acolomb wants to merge 1 commit into
Conversation
If an EMCY package was received, but filtered out by the emcy_code matching, the condition waiting is started again with the same timeout. Thus the actual maximum waiting time is not correctly limited to the given argument, as the docstring promises. Track the remaining time until the initial deadline instead, as basis for the condition wait. Further, spurious wake-ups from the condition wait on the OS level are not handled correctly. The threading.Condition docs explicitly recommend checking the shared state (number of logged entries in this case) in the while loop, because the wait() call may abort early. The current code assumes that this necessarily indicates a timeout, without checking the actually passed time again. Reorder the check against end_time in the loop to avoid this.
Codecov Report❌ Patch coverage is
📢 Thoughts on this report? Let us know! |
Member
Author
|
This was discovered while reviewing the tests in #659. Let's merge that one first to have an accurate picture of the test coverage. Will add some more specific tests regarding this failure mode subsequently. |
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.
If an EMCY package was received, but filtered out by the emcy_code matching, the condition waiting is started again with the same timeout. Thus the actual maximum waiting time is not correctly limited to the given argument, as the docstring promises. Track the remaining time until the initial deadline instead, as basis for the condition wait.
Further, spurious wake-ups from the condition wait on the OS level are not handled correctly. The threading.Condition docs explicitly recommend checking the shared state (number of logged entries in this case) in the while loop, because the wait() call may abort early. The current code assumes that this necessarily indicates a timeout, without checking the actually passed time again. Reorder the check against end_time in the loop to avoid this.