Skip to content

[3.6] bpo-35347: Fix test_socket.NonBlockingTCPTests (GH-10791)#10816

Merged
miss-islington merged 1 commit into
python:3.6from
miss-islington:backport-ebd5d6d-3.6
Nov 30, 2018
Merged

[3.6] bpo-35347: Fix test_socket.NonBlockingTCPTests (GH-10791)#10816
miss-islington merged 1 commit into
python:3.6from
miss-islington:backport-ebd5d6d-3.6

Conversation

@miss-islington

@miss-islington miss-islington commented Nov 30, 2018

Copy link
Copy Markdown
Contributor

testAccept() and testRecv() of test_socket.NonBlockingTCPTests have a
race condition: time.sleep() is used as a weak synchronization
primitive and the tests fail randomly on slow buildbots.

Use a reliable threading.Event to fix these tests.

Other changes:

  • Replace send() with sendall()
  • Expect specific BlockingIOError rather than generic OSError
  • Add a timeout to select() in testAccept() and testRecv()
  • Use addCleanup() to close sockets
  • Use assertRaises()
    (cherry picked from commit ebd5d6d)

Co-authored-by: Victor Stinner vstinner@redhat.com

https://bugs.python.org/issue35347

testAccept() and testRecv() of test_socket.NonBlockingTCPTests have a
race condition: time.sleep() is used as a weak synchronization
primitive and the tests fail randomly on slow buildbots.

Use a reliable threading.Event to fix these tests.

Other changes:

* Replace send() with sendall()
* Expect specific BlockingIOError rather than generic OSError
* Add a timeout to select() in testAccept() and testRecv()
* Use addCleanup() to close sockets
* Use assertRaises()
(cherry picked from commit ebd5d6d)

Co-authored-by: Victor Stinner <vstinner@redhat.com>

@vstinner vstinner left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM, good bot.

@miss-islington

Copy link
Copy Markdown
Contributor Author

@vstinner: Status check is done, and it's a success ✅ .

@miss-islington miss-islington merged commit af7e81f into python:3.6 Nov 30, 2018
@miss-islington miss-islington deleted the backport-ebd5d6d-3.6 branch November 30, 2018 11:51
@miss-islington

Copy link
Copy Markdown
Contributor Author

@vstinner: Status check is done, and it's a success ✅ .

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.

4 participants