diff options
author | Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com> | 2019-02-26 16:18:23 (GMT) |
---|---|---|
committer | Victor Stinner <vstinner@redhat.com> | 2019-02-26 16:18:23 (GMT) |
commit | 53b9e1a1c1d86187ad6fbee492b697ef8be74205 (patch) | |
tree | ed814854c27a217d81d8b26ed36421536ca692a8 /Lib/test/test_socket.py | |
parent | c606a9cbd48f69d3f4a09204c781dda9864218b7 (diff) | |
download | cpython-53b9e1a1c1d86187ad6fbee492b697ef8be74205.zip cpython-53b9e1a1c1d86187ad6fbee492b697ef8be74205.tar.gz cpython-53b9e1a1c1d86187ad6fbee492b697ef8be74205.tar.bz2 |
bpo-36123: Fix test_socket.testWithTimeoutTriggeredSend() race condition (GH-12053)
Use longer timeout for accept() in the server and block on accept in the client.
The client now only sets the timeout once the socket is connected.
Diffstat (limited to 'Lib/test/test_socket.py')
-rw-r--r-- | Lib/test/test_socket.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/Lib/test/test_socket.py b/Lib/test/test_socket.py index 7c5167d..571f45c 100644 --- a/Lib/test/test_socket.py +++ b/Lib/test/test_socket.py @@ -5603,7 +5603,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest): support.unlink(support.TESTFN) def accept_conn(self): - self.serv.settimeout(self.TIMEOUT) + self.serv.settimeout(MAIN_TIMEOUT) conn, addr = self.serv.accept() conn.settimeout(self.TIMEOUT) self.addCleanup(conn.close) @@ -5788,7 +5788,8 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest): def _testWithTimeoutTriggeredSend(self): address = self.serv.getsockname() with open(support.TESTFN, 'rb') as file: - with socket.create_connection(address, timeout=0.01) as sock: + with socket.create_connection(address) as sock: + sock.settimeout(0.01) meth = self.meth_from_sock(sock) self.assertRaises(socket.timeout, meth, file) |