[New-bugs-announce] [issue18455] Multiprocessing connection SocketClient retries connection on socket

Michael Ballantyne report at bugs.python.org
Mon Jul 15 01:24:20 CEST 2013


New submission from Michael Ballantyne:

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.

----------
assignee: ronaldoussoren
components: Library (Lib), Macintosh
messages: 193069
nosy: Michael.Ballantyne, ronaldoussoren
priority: normal
severity: normal
status: open
title: Multiprocessing connection SocketClient retries connection on socket
type: behavior
versions: Python 2.6, Python 2.7, Python 3.1, Python 3.2

_______________________________________
Python tracker <report at bugs.python.org>
<http://bugs.python.org/issue18455>
_______________________________________


More information about the New-bugs-announce mailing list