--- orig-asyncore.py 2010-09-15 23:08:22.000000000 +0600 +++ asyncore.py 2011-03-02 02:37:11.753776252 +0500 @@ -53,7 +53,8 @@ import os from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, \ - ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, errorcode + ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, \ + EAGAIN, errorcode, EPIPE try: socket_map @@ -108,8 +109,7 @@ if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL): obj.handle_close() except socket.error, e: - if e.args[0] not in (EBADF, ECONNRESET, ENOTCONN, ESHUTDOWN, -ECONNABORTED): + if e.args[0] not in (EBADF, ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE): obj.handle_error() else: obj.handle_close() @@ -336,7 +336,7 @@ self.connected = False err = self.socket.connect_ex(address) # XXX Should interpret Winsock return values - if err in (EINPROGRESS, EALREADY, EWOULDBLOCK): + if err in (EINPROGRESS, EALREADY, EWOULDBLOCK, EAGAIN): return if err in (0, EISCONN): self.addr = address @@ -350,7 +350,7 @@ conn, addr = self.socket.accept() return conn, addr except socket.error, why: - if why.args[0] == EWOULDBLOCK: + if why.args[0] in (EWOULDBLOCK, EAGAIN): pass else: raise @@ -360,9 +360,9 @@ result = self.socket.send(data) return result except socket.error, why: - if why.args[0] == EWOULDBLOCK: + if why.args[0] in (EWOULDBLOCK, EAGAIN): return 0 - elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED): + elif why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE): self.handle_close() return 0 else: @@ -380,7 +380,7 @@ return data except socket.error, why: # winsock sometimes throws ENOTCONN - if why.args[0] in [ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED]: + if why.args[0] in (ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE): self.handle_close() return '' else: