This issue tracker has been migrated to GitHub, and is currently read-only.
For more information, see the GitHub FAQs in the Python's Developer Guide.

Author Benjamin.Ash
Recipients Alexey.Agapitov, Benjamin.Ash, giampaolo.rodola, neologix, python-dev, rosslagerwall, vstinner
Date 2013-02-04.16:31:26
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1359995486.55.0.675667544046.issue12502@psf.upfronthosting.co.za>
In-reply-to
Content
After doing a bit more testing, I was able to prevent the problem from occurring in asyncore_test.py with the following patch:

--- /proc/self/fd/11	2013-02-04 11:24:41.298347199 -0500
+++ asyncore_test.py	2013-02-04 11:24:40.393318513 -0500
@@ -19,10 +19,18 @@
         self.bind(sock)
         self.listen(5)
 
-    def handle_accepted(self, sock, addr):
-        print('Incoming connection from %s' % repr(addr))
-        handler = EchoHandler(sock)
+    def handle_accept(self):
+        pair = self.accept()
+        if pair is not None:
+            (sock, addr) = pair
+            print('Incoming connection from %s' % repr(addr))
+            handler = EchoHandler(sock)

Using handle_accept() in my code and remembering to call listen() in my asyncore.dispatcher server's constructor did the trick.

I am not sure if we still have a bug here though, since if the subclass doesn't define  a proper handle_accept() we get into the select() loop and 100% CPU utilization after the initial client connection.
History
Date User Action Args
2013-02-04 16:31:26Benjamin.Ashsetrecipients: + Benjamin.Ash, vstinner, giampaolo.rodola, neologix, rosslagerwall, python-dev, Alexey.Agapitov
2013-02-04 16:31:26Benjamin.Ashsetmessageid: <1359995486.55.0.675667544046.issue12502@psf.upfronthosting.co.za>
2013-02-04 16:31:26Benjamin.Ashlinkissue12502 messages
2013-02-04 16:31:26Benjamin.Ashcreate