]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-35347: Fix test_socket.NonBlockingTCPTests (GH-10791)
authorMiss Islington (bot) <31488909+miss-islington@users.noreply.github.com>
Fri, 30 Nov 2018 11:48:17 +0000 (03:48 -0800)
committerGitHub <noreply@github.com>
Fri, 30 Nov 2018 11:48:17 +0000 (03:48 -0800)
commit365f21c2d3756a6768c5b0d479aaf5c2a568b80b
treea180d9c9ab20bc608f3970a65d94c0724be5d31b
parentdf738d56fe798b3586ed71775df25bf127789cf6
bpo-35347: Fix test_socket.NonBlockingTCPTests (GH-10791)

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 ebd5d6d6e6e4e751ba9c7534004aadfc27ba9265)

Co-authored-by: Victor Stinner <vstinner@redhat.com>
Lib/test/test_socket.py