This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

classification
Title: Race condition in test_socket
Type: behavior Stage: resolved
Components: Tests Versions: Python 3.8
process
Status: closed Resolution:
Dependencies: Superseder:
Assigned To: Nosy List: miss-islington, nanjekyejoannah, vstinner
Priority: normal Keywords: patch

Created on 2019-02-26 12:43 by nanjekyejoannah, last changed 2022-04-11 14:59 by admin. This issue is now closed.

Pull Requests
URL Status Linked Edit
PR 12053 merged nanjekyejoannah, 2019-02-26 12:47
PR 12056 merged miss-islington, 2019-02-26 16:18
Messages (4)
msg336658 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-02-26 12:43
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.
msg336690 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2019-02-26 16:18
New changeset 53b9e1a1c1d86187ad6fbee492b697ef8be74205 by Victor Stinner (Joannah Nanjekye) in branch 'master':
bpo-36123: Fix test_socket.testWithTimeoutTriggeredSend() race condition (GH-12053)
https://github.com/python/cpython/commit/53b9e1a1c1d86187ad6fbee492b697ef8be74205
msg336694 - (view) Author: miss-islington (miss-islington) Date: 2019-02-26 16:48
New changeset 2632474957fa9c6311af21be6906d1234853f288 by Miss Islington (bot) in branch '3.7':
bpo-36123: Fix test_socket.testWithTimeoutTriggeredSend() race condition (GH-12053)
https://github.com/python/cpython/commit/2632474957fa9c6311af21be6906d1234853f288
msg336704 - (view) Author: Joannah Nanjekye (nanjekyejoannah) * (Python committer) Date: 2019-02-26 17:50
I am closing this as it has been fixed by this PR <https://github.com/python/cpython/pull/12053>
History
Date User Action Args
2022-04-11 14:59:11adminsetgithub: 80304
2019-02-26 17:50:28nanjekyejoannahsetstatus: open -> closed

messages: + msg336704
stage: patch review -> resolved
2019-02-26 16:48:55miss-islingtonsetnosy: + miss-islington
messages: + msg336694
2019-02-26 16:18:49miss-islingtonsetpull_requests: + pull_request12081
2019-02-26 16:18:26vstinnersetnosy: + vstinner
messages: + msg336690
2019-02-26 12:47:24nanjekyejoannahsetkeywords: + patch
stage: patch review
pull_requests: + pull_request12079
2019-02-26 12:43:13nanjekyejoannahcreate