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: Multiprocessing connection SocketClient retries connection on socket
Type: behavior Stage: resolved
Components: Library (Lib), macOS Versions: Python 3.1, Python 3.2, Python 2.7, Python 2.6
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: Michael.Ballantyne, python-dev, ronaldoussoren, sbt
Priority: normal Keywords:

Created on 2013-07-14 23:24 by Michael.Ballantyne, last changed 2022-04-11 14:57 by admin. This issue is now closed.

Messages (3)
msg193069 - (view) Author: Michael Ballantyne (Michael.Ballantyne) Date: 2013-07-14 23:24
from multiprocessing/connection.py:
while 1:
        try:
            s.connect(address)
        except socket.error, e:
            if e.args[0] != errno.ECONNREFUSED or _check_timeout(t):
                debug('failed to connect to address %s', address)
                raise
            time.sleep(0.01)
        else:
            break
    else:
        raise


According to the POSIX spec http://pubs.opengroup.org/onlinepubs/9699919799/
"If connect() fails, the state of the socket is unspecified. Conforming applications should close the file descriptor and create a new socket before attempting to reconnect."

On Mac OS X and other BSDs (but not Linux), attempting to connect() again throws EINVAL. As a result, the multiprocessing.connection.Client does not successfully retry, and instead throws 
socket.error: [Errno 22] Invalid argument 
after the first refused connection. I found that error message pretty confusing, and didn't realize that it effectively meant the connection was refused.

The change for issue #13215 removes the retry behavior entirely, so this bug does not appear in 3.3 and up.
msg193121 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2013-07-15 17:39
New changeset 542a317d4351 by Richard Oudkerk in branch '2.7':
Issue #18455: multiprocessing should not retry connect() with same socket.
http://hg.python.org/cpython/rev/542a317d4351
msg193126 - (view) Author: Richard Oudkerk (sbt) * (Python committer) Date: 2013-07-15 19:34
Thanks for the report.

This should be fixed now in 2.7.  (3.1 and 3.2 only get security fixes.)
History
Date User Action Args
2022-04-11 14:57:48adminsetgithub: 62655
2013-07-15 19:34:43sbtsetstatus: open -> closed
resolution: fixed
messages: + msg193126

stage: resolved
2013-07-15 17:39:06python-devsetnosy: + python-dev
messages: + msg193121
2013-07-15 06:59:03ronaldoussorensetassignee: ronaldoussoren ->
2013-07-14 23:39:36sbtsetnosy: + sbt
2013-07-14 23:24:20Michael.Ballantynecreate