Skip to content

Commit

Permalink
bpo-36123: Fix test_socket.testWithTimeoutTriggeredSend() race condit…
Browse files Browse the repository at this point in the history
…ion (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.
  • Loading branch information
nanjekyejoannah authored and vstinner committed Feb 26, 2019
1 parent c606a9c commit 53b9e1a
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 2 deletions.
5 changes: 3 additions & 2 deletions Lib/test/test_socket.py
Expand Up @@ -5603,7 +5603,7 @@ def tearDownClass(cls):
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)
Expand Down Expand Up @@ -5788,7 +5788,8 @@ def testWithTimeout(self):
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)

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

0 comments on commit 53b9e1a

Please sign in to comment.