Issue 36123: Race condition in test_socket (original) (raw)
Looking at the buildbot failures, there is a race condition in a test_socket test:
def _testWithTimeoutTriggeredSend(self):
address = self.serv.getsockname()
with open(support.TESTFN, 'rb') as file:
with socket.create_connection(address, timeout=0.01) as sock:
meth = self.meth_from_sock(sock)
self.assertRaises(socket.timeout, meth, file)
def testWithTimeoutTriggeredSend(self):
conn = self.accept_conn()
conn.recv(88192)
on slow buildbot, create_connection() fails with a timeout exception sometimes because the server fails to start listing in less than 10 ms.
https://buildbot.python.org/all/#/builders/167/builds/597
====================================================================== ERROR: testWithTimeoutTriggeredSend (test.test_socket.SendfileUsingSendTest)
Traceback (most recent call last): File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py", line 5796, in testWithTimeoutTriggeredSend conn = self.accept_conn() File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py", line 5607, in accept_conn conn, addr = self.serv.accept() File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/socket.py", line 212, in accept fd, addr = self._accept() socket.timeout: timed out
====================================================================== ERROR: testWithTimeoutTriggeredSend (test.test_socket.SendfileUsingSendTest)
Traceback (most recent call last): File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py", line 335, in _tearDown raise exc File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py", line 353, in clientRun test_func() File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/test/test_socket.py", line 5791, in _testWithTimeoutTriggeredSend with socket.create_connection(address, timeout=0.01) as sock: File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/socket.py", line 727, in create_connection raise err File "/usr/home/buildbot/python/3.x.koobs-freebsd10.nondebug/build/Lib/socket.py", line 716, in create_connection sock.connect(sa) socket.timeout: timed out
Note: Reported my Victor. I created the bug to track.