-
-
Notifications
You must be signed in to change notification settings - Fork 33.4k
bpo-34130: Fix test_signal.test_socket() #8326
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
Merged
Merged
Conversation
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
Sometimes on Windows, test_signal.test_socket() fails on recv(1) with BlockingIOError. The C signal handler wrote the signal number using send() which returns 1 byte as expected, but the read end of the socket pair doesn't get "immediately" the byte. Configure the read end of the socket pair as blocking to wait until we get the signal number and so fix the race condition on Windows.
Member
Author
|
The first version of my PR included unrelated minor changes, I chose to revert them to make the PR much simpler to backport (it's now a single line removed). |
Contributor
|
Thanks @vstinner for the PR 🌮🎉.. I'm working now to backport this PR to: 3.6. |
|
GH-8330 is a backport of this pull request to the 3.6 branch. |
miss-islington
pushed a commit
to miss-islington/cpython
that referenced
this pull request
Jul 18, 2018
test_signal.test_socket(): On Windows, sometimes even if the C signal handler succeed to write the signal number into the write end of the socketpair, the test fails with a BlockingIOError on the non-blocking read.recv(1) because the read end of the socketpair didn't receive the byte yet. Fix the race condition on Windows by setting the read end as blocking. (cherry picked from commit 99bb6df) Co-authored-by: Victor Stinner <[email protected]>
vstinner
added a commit
that referenced
this pull request
Jul 18, 2018
* bpo-34130: Fix test_signal.test_socket() (GH-8326) test_signal.test_socket(): On Windows, sometimes even if the C signal handler succeed to write the signal number into the write end of the socketpair, the test fails with a BlockingIOError on the non-blocking read.recv(1) because the read end of the socketpair didn't receive the byte yet. Fix the race condition on Windows by setting the read end as blocking. (cherry picked from commit 99bb6df) * bpo-34130: Fix test_signal.test_warn_on_full_buffer() (GH-8327) On Windows, sometimes test_signal.test_warn_on_full_buffer() fails to fill the socketpair buffer. In that case, the C signal handler succeed to write into the socket, it doesn't log the expected send error, and so the test fail. On Windows, the test now uses a timeout of 50 ms to fill the socketpair buffer to fix this race condition. Other changes: * Begin with large chunk size to fill the buffer to speed up the test. * Add error messages to assertion errors to more easily identify which assertion failed. * Don't set the read end of the socketpair as non-blocking. (cherry picked from commit 686b4b5)
vstinner
added a commit
that referenced
this pull request
Jul 18, 2018
test_signal.test_socket(): On Windows, sometimes even if the C signal handler succeed to write the signal number into the write end of the socketpair, the test fails with a BlockingIOError on the non-blocking read.recv(1) because the read end of the socketpair didn't receive the byte yet. Fix the race condition on Windows by setting the read end as blocking. (cherry picked from commit 99bb6df) Co-authored-by: Victor Stinner <[email protected]>
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.
Sometimes on Windows, test_signal.test_socket() fails on recv(1) with
BlockingIOError. The C signal handler wrote the signal number using
send() which returns 1 byte as expected, but the read end of the
socket pair doesn't get "immediately" the byte.
Configure the read end of the socket pair as blocking to wait until
we get the signal number and so fix the race condition on Windows.
Use also "with" context manager to ensure that the sockets are closed
even if the test fails.
https://bugs.python.org/issue34130