--- socket.py 2011-12-21 05:25:06.000000000 +0900 +++ socket.py.fix 2014-05-29 19:01:29.000000000 +0900 @@ -553,19 +553,22 @@ for res in getaddrinfo(host, port, 0, SOCK_STREAM): af, socktype, proto, canonname, sa = res sock = None - try: - sock = socket(af, socktype, proto) - if timeout is not _GLOBAL_DEFAULT_TIMEOUT: - sock.settimeout(timeout) - if source_address: - sock.bind(source_address) - sock.connect(sa) - return sock + while True: + try: + sock = socket(af, socktype, proto) + if timeout is not _GLOBAL_DEFAULT_TIMEOUT: + sock.settimeout(timeout) + if source_address: + sock.bind(source_address) + sock.connect(sa) + return sock - except error as _: - err = _ - if sock is not None: - sock.close() + except error as _: + err = _ + if sock is not None: + sock.close() + if err.args[0] == EINTR: + continue if err is not None: raise err