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 kristjan.jonsson
Recipients MJ, kristjan.jonsson, paul.moore, steve.dower, terry.reedy, tim.golden, zach.ware
Date 2016-04-24.10:30:23
SpamBayes Score -1.0
Marked as misclassified Yes
Message-id <1461493823.75.0.389273719522.issue26739@psf.upfronthosting.co.za>
In-reply-to
Content
Caveat emptor:  I know nothing of IDLE, and I even suspect it to be dead or dying code.  Non the less, it could be patched.

I found this in the code:
def putmessage(self, message):
        self.debug("putmessage:%d:" % message[0])
        try:
            s = pickle.dumps(message)
        except pickle.PicklingError:
            print >>sys.__stderr__, "Cannot pickle:", repr(message)
            raise
        s = struct.pack("<i", len(s)) + s
        while len(s) > 0:
            try:
                r, w, x = select.select([], [self.sock], [])
                n = self.sock.send(s[:BUFSIZE])
            except (AttributeError, TypeError):
                raise IOError, "socket no longer exists"
            except socket.error:
                raise
            else:
                s = s[n:]


If the socket were non-blocking, this would be the place to add a handler to catch socket.error with errno=errno.EWOULDBLOCK

However, I can't see that this socket is non-blocking.  Perhaps I have some blindness, but the select calls seem to be redundant to me, I can't see any sock.setblocking(False) or sock.settimeout(0.0) being done anywhere.


Having said that, the following change can be made (which is the prudent way to use select/send anyway)
while len(s) > 0:
            try:
                while True:
                r, w, x = select.select([], [self.sock], [])
                try:
                    n = self.sock.send(s[:BUFSIZE])
                    break
                except socket.error as e:
                    import errno # should be done at the top
                    if e.errno != errno.EWOULDBLOCK:
                        raise
            except (AttributeError, TypeError):
                raise IOError, "socket no longer exists"
            except socket.error:
                raise
            else:
                s = s[n:]
History
Date User Action Args
2016-04-24 10:30:23kristjan.jonssonsetrecipients: + kristjan.jonsson, terry.reedy, paul.moore, tim.golden, zach.ware, steve.dower, MJ
2016-04-24 10:30:23kristjan.jonssonsetmessageid: <1461493823.75.0.389273719522.issue26739@psf.upfronthosting.co.za>
2016-04-24 10:30:23kristjan.jonssonlinkissue26739 messages
2016-04-24 10:30:23kristjan.jonssoncreate