changeset 68216:208a5290fd38

Fix issue 11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors on accept(), recv() and send().
author Giampaolo Rodolà <g.rodola@gmail.com>
date Thu, 03 Mar 2011 13:57:47 +0000
parents 20a5a08c3b6c
children f5398fb81428
files Lib/asyncore.py Misc/NEWS
diffstat 2 files changed, 8 insertions(+), 4 deletions(-) [+]
line wrap: on
line diff
--- a/Lib/asyncore.py	Thu Mar 03 12:54:07 2011 +0000
+++ b/Lib/asyncore.py	Thu Mar 03 13:57:47 2011 +0000
@@ -54,9 +54,10 @@
 
 import os
 from errno import EALREADY, EINPROGRESS, EWOULDBLOCK, ECONNRESET, EINVAL, \
-     ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, errorcode
+     ENOTCONN, ESHUTDOWN, EINTR, EISCONN, EBADF, ECONNABORTED, EPIPE, errorcode
 
-_DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED))
+_DISCONNECTED = frozenset((ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED, EPIPE,
+                           EBADF))
 
 try:
     socket_map
@@ -111,7 +112,7 @@
         if flags & (select.POLLHUP | select.POLLERR | select.POLLNVAL):
             obj.handle_close()
     except socket.error as e:
-        if e.args[0] not in (EBADF, ECONNRESET, ENOTCONN, ESHUTDOWN, ECONNABORTED):
+        if e.args[0] not in _DISCONNECTED:
             obj.handle_error()
         else:
             obj.handle_close()
@@ -355,7 +356,7 @@
         except TypeError:
             return None
         except socket.error as why:
-            if why.args[0] in (EWOULDBLOCK, ECONNABORTED):
+            if why.args[0] in (EWOULDBLOCK, ECONNABORTED, EAGAIN):
                 return None
             else:
                 raise
--- a/Misc/NEWS	Thu Mar 03 12:54:07 2011 +0000
+++ b/Misc/NEWS	Thu Mar 03 13:57:47 2011 +0000
@@ -52,6 +52,9 @@
 Library
 -------
 
+- Issue #11265: asyncore now correctly handles EPIPE, EBADF and EAGAIN errors
+  on accept(), send() and recv().
+
 - Issue #11377: Deprecate platform.popen() and reimplement it with os.popen().
 
 - Issue #8513: On UNIX, subprocess supports bytes command string.