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.
This commit is contained in:
Joannah Nanjekye 2019-02-26 19:18:23 +03:00 committed by Victor Stinner
parent c606a9cbd4
commit 53b9e1a1c1
2 changed files with 4 additions and 2 deletions

View File

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

View File

@ -0,0 +1 @@
Fix race condition in test_socket.