diff -r 5fbf0d010276 Lib/multiprocessing/connection.py --- a/Lib/multiprocessing/connection.py Mon Jun 13 14:59:36 2011 +0100 +++ b/Lib/multiprocessing/connection.py Thu Jun 16 02:04:54 2011 -0400 @@ -186,6 +186,11 @@ ''' if duplex: s1, s2 = socket.socketpair() + # _multiprocessing.Connection read/write semantics do not handle + # non-blocking sockets correctly (issue 6056). This bug-fix + # retains current behavior and allows for a default socket timeout + s1.settimeout(None) + s2.settimeout(None) c1 = _multiprocessing.Connection(os.dup(s1.fileno())) c2 = _multiprocessing.Connection(os.dup(s2.fileno())) s1.close() @@ -250,6 +255,8 @@ def __init__(self, address, family, backlog=1): self._socket = socket.socket(getattr(socket, family)) self._socket.setsockopt(socket.SOL_SOCKET, socket.SO_REUSEADDR, 1) + # non-blocking sockets fix for issue 6056 + self._socket.settimeout(None) self._socket.bind(address) self._socket.listen(backlog) self._address = self._socket.getsockname() @@ -265,6 +272,8 @@ def accept(self): s, self._last_accepted = self._socket.accept() + # non-blocking sockets fix for issue 6056 + s.settimeout(None) fd = duplicate(s.fileno()) conn = _multiprocessing.Connection(fd) s.close() @@ -282,6 +291,8 @@ ''' family = address_type(address) s = socket.socket( getattr(socket, family) ) + # non-blocking sockets fix for issue 6056 + s.settimeout(None) t = _init_timeout() while 1: diff -r 5fbf0d010276 Lib/test/test_multiprocessing.py --- a/Lib/test/test_multiprocessing.py Mon Jun 13 14:59:36 2011 +0100 +++ b/Lib/test/test_multiprocessing.py Thu Jun 16 02:04:54 2011 -0400 @@ -2105,6 +2105,10 @@ def main(): test_main(unittest.TextTestRunner(verbosity=2).run) + # run all tests again with non-blocking sockets and positive timeout + # see Issue 6056 + socket.setdefaulttimeout(60) + test_main(unittest.TextTestRunner(verbosity=2).run) if __name__ == '__main__': main() diff -r 5fbf0d010276 Misc/ACKS --- a/Misc/ACKS Mon Jun 13 14:59:36 2011 +0100 +++ b/Misc/ACKS Thu Jun 16 02:04:54 2011 -0400 @@ -879,6 +879,7 @@ Sue Williams Gerald S. Williams Frank Willison +J Derek Wilson Greg V. Wilson Jody Winston Collin Winter diff -r 5fbf0d010276 Misc/NEWS --- a/Misc/NEWS Mon Jun 13 14:59:36 2011 +0100 +++ b/Misc/NEWS Thu Jun 16 02:04:54 2011 -0400 @@ -16,6 +16,9 @@ Library ------- +- Issue #6056: Allow socket.setdefaulttimeout to work with _mutliprocessing + socket interface that expects blocking sockets. + - Issue #9284: Allow inspect.findsource() to find the source of doctest functions.