diff Lib/asyncore.py @ 65088:c28fdeeea786

Fix issue 6706: adds new handle_accepted() method to asyncore.dispatcher
author Giampaolo Rodolà <g.rodola@gmail.com>
date Mon, 04 Oct 2010 21:08:36 +0000
parents b5774b27b3db
children 5dfe0c42ffe8
line wrap: on
line diff
--- a/Lib/asyncore.py	Mon Oct 04 15:48:14 2010 +0000
+++ b/Lib/asyncore.py	Mon Oct 04 21:08:36 2010 +0000
@@ -352,12 +352,15 @@
         # XXX can return either an address pair or None
         try:
             conn, addr = self.socket.accept()
-            return conn, addr
+        except TypeError:
+            return None
         except socket.error as why:
-            if why.args[0] == EWOULDBLOCK:
-                pass
+            if why.args[0] in (EWOULDBLOCK, ECONNABORTED):
+                return None
             else:
                 raise
+        else:
+            return conn, addr
 
     def send(self, data):
         try:
@@ -506,7 +509,13 @@
         self.log_info('unhandled connect event', 'warning')
 
     def handle_accept(self):
-        self.log_info('unhandled accept event', 'warning')
+        pair = self.accept()
+        if pair is not None:
+            self.handle_accepted(*pair)
+
+    def handle_accepted(self, sock, addr):
+        sock.close()
+        self.log_info('unhandled accepted event', 'warning')
 
     def handle_close(self):
         self.log_info('unhandled close event', 'warning')