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 Nidan
Recipients Nidan
Date 2012-10-04.16:06:32
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <>
I recently had lots of the following exception:
error: uncaptured python exception, closing channel <servercore_persistent.ConnectionHandler connected at 0x8d27eec> (<class 'socket.error'>:[Errno 11] Resource temporarily unavailable [/usr/lib/python2.7/|handle_read|110] [/usr/lib/python2.7/|recv|384])

Error 11 is EAGAIN or EWOULDBLOCK, so asyncore/asynchat tries to read from a nonblocking socket which has no data available. Since this is a temporary error the socket shouldn't be closed.

The bug can be fixed by changing asyncore.dispatcher.recv to
    def recv(self, buffer_size):
            data = self.socket.recv(buffer_size)
            if not data:
                # a closed connection is indicated by signaling
                # a read condition, and having recv() return 0.
                return ''
                return data
        except socket.error, why:
            # winsock sometimes throws ENOTCONN
            if why.args[0] in _DISCONNECTED:
                return ''
            elif why.args[0] in (EAGAIN, EWOULDBLOCK):
                return ''

While looking at the source I also saw that asyncore.dispatcher.send and .connect check against EWOULDBLOCK but not against EAGAIN. Since both constants may have different values and POSIX allows to return either of them these functions should check against both error constants.
Date User Action Args
2012-10-04 16:06:32Nidansetrecipients: + Nidan
2012-10-04 16:06:32Nidansetmessageid: <>
2012-10-04 16:06:32Nidanlinkissue16133 messages
2012-10-04 16:06:32Nidancreate