Skip to content
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

bpo-34130: Fix test_signal.test_warn_on_full_buffer() #8327

Merged
merged 1 commit into from Jul 18, 2018
Merged

bpo-34130: Fix test_signal.test_warn_on_full_buffer() #8327

merged 1 commit into from Jul 18, 2018

Conversation

vstinner
Copy link
Member

@vstinner vstinner commented Jul 18, 2018

Sometimes on Windows, test_signal.test_warn_on_full_buffer() fails on
fill the socketpair buffer, the C signal handler succeed to write
into the socket and so doesn't log the expected send error, and the
test fail.

Retry the test a second time if the first attempt failed to fill the
buffer.

Speed-up also the code filling the socketpair: being with writing
64 KiB chunks, instead of only write byte per byte.

Add also error messages to assertion errors to more easily identify
which assertion failed.

https://bugs.python.org/issue34130

@vstinner
Copy link
Member Author

Oh. test_warn_on_full_buffer() still fails randomly with this PR :-(

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:

* Being 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.
@vstinner
Copy link
Member Author

Hum, I rewrote my PR 3 times.

My first attempts were optimistic: loop until non-blocking send() stop failing with BlockingIOError.

My latest PR uses a timeout of 50 ms as a workaround for the issue.

@vstinner
Copy link
Member Author

Without my PR, test_warn_on_full_buffer() takes 4.2 seconds because of the inefficient loop filling the socketpair. With this PR, the test now only takes 600 ms: it's now 7x faster even with the additional timeouts.

@vstinner vstinner merged commit 686b4b5 into python:master Jul 18, 2018
@vstinner vstinner deleted the signal_test_warn_on_full_buffer branch July 18, 2018 16:29
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)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
skip news tests Tests in the Lib/test dir
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants