Uncatchable socket.error in socket.py (?)

Raymond Hettinger vze4rx4y at verizon.net
Tue Aug 26 16:45:32 EDT 2003


> > I cannot connect to the server any longer and connection.send(data)
> > will generate a new socket.error: (9, 'Bad file descriptor')
>
> I see; it wasn't entirely clear to me what your complaint was from your
> first message.  If you're getting an exception when calling recv, the
> connection has already dropped.  You can't send the message because the
> connection isn't there anymore.  Catching or not catching an exception
> won't change that.

Guido handles this situation using timemachine exceptions:

    try:
        communicationcode()
    unrecoverable_except socket.error:
        alternatecode()

This works as expected.  If the communciation code raises an
unrecoverable exception, then time is backed up to just before
the communication code was executed and the alternate code
is run instead.

I believe he intends to incorporate this feature in his next
language, Voyager, which is named after a Star Trek spin-off.
The idea is not really new; it is just an extension of commit/rollback
for socketlike objects where the state (uncrashed) is not easily
restored without access to timemachine hardware.


Raymond Hettinger






More information about the Python-list mailing list