]> git.ipfire.org Git - thirdparty/Python/cpython.git/commit
bpo-35347: Fix test_socket.NonBlockingTCPTests (GH-10791) (GH-10817)
authorVictor Stinner <vstinner@redhat.com>
Fri, 30 Nov 2018 12:02:41 +0000 (13:02 +0100)
committerGitHub <noreply@github.com>
Fri, 30 Nov 2018 12:02:41 +0000 (13:02 +0100)
commitdab59fa56054d6c0f75ae7013337f7baaa248076
treea407f556993309fffebc09816c5997b0511ddfad
parentd7a880c3c2b73415a42c8a2f900c6bc597de115d
bpo-35347: Fix test_socket.NonBlockingTCPTests (GH-10791) (GH-10817)

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()
* Add a timeout to select() in testAccept() and testRecv()
* Use addCleanup() to close sockets
* Use assertRaises()

(cherry picked from commit ebd5d6d6e6e4e751ba9c7534004aadfc27ba9265)
Lib/test/test_socket.py