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.
(cherry picked from commit 53b9e1a1c1
)
Co-authored-by: Joannah Nanjekye <33177550+nanjekyejoannah@users.noreply.github.com>
This commit is contained in:
parent
4e6646fef5
commit
2632474957
|
@ -5533,7 +5533,7 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
|
||||||
support.unlink(support.TESTFN)
|
support.unlink(support.TESTFN)
|
||||||
|
|
||||||
def accept_conn(self):
|
def accept_conn(self):
|
||||||
self.serv.settimeout(self.TIMEOUT)
|
self.serv.settimeout(MAIN_TIMEOUT)
|
||||||
conn, addr = self.serv.accept()
|
conn, addr = self.serv.accept()
|
||||||
conn.settimeout(self.TIMEOUT)
|
conn.settimeout(self.TIMEOUT)
|
||||||
self.addCleanup(conn.close)
|
self.addCleanup(conn.close)
|
||||||
|
@ -5718,7 +5718,8 @@ class SendfileUsingSendTest(ThreadedTCPSocketTest):
|
||||||
def _testWithTimeoutTriggeredSend(self):
|
def _testWithTimeoutTriggeredSend(self):
|
||||||
address = self.serv.getsockname()
|
address = self.serv.getsockname()
|
||||||
with open(support.TESTFN, 'rb') as file:
|
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)
|
meth = self.meth_from_sock(sock)
|
||||||
self.assertRaises(socket.timeout, meth, file)
|
self.assertRaises(socket.timeout, meth, file)
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1 @@
|
||||||
|
Fix race condition in test_socket.
|
Loading…
Reference in New Issue