msgq: refactor blocking recv for improved robustness and performance #616
+77
−68
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.
Replaced the previous method of installing, saving, and restoring signal handlers with a more streamlined and standard approach using signal masks (pthread_sigmask, sigtimedwait) for blocking receive operations. This update enhances the consistency and reliability of signal handling, aligning with best practices. It also removes the need for
msgq_poll
, thereby improving the efficiency of the receive function.Additionally, a new test case,
test_receive_interrupts_on_sigint
, has been added to confirm and verify the functionality of the updated signal handling.Since signal blocking is now managed in the C++ code,
nogil
is used in the Cython code to ensure the GIL is released during the execution of the receive function. This prevents it from impacting other Python threads.