[Python-bugs-list] [ python-Bugs-758239 ] socket timeout exception unhelpful

SourceForge.net noreply@sourceforge.net
Wed, 25 Jun 2003 08:20:18 -0700


Bugs item #758239, was opened at 2003-06-20 20:27
Message generated for change (Comment added) made by rhettinger
You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=758239&group_id=5470

Category: Python Library
Group: Python 2.3
Status: Open
Resolution: None
Priority: 5
Submitted By: Bob Halley (rthalley)
>Assigned to: Guido van Rossum (gvanrossum)
Summary: socket timeout exception unhelpful

Initial Comment:
The new settimeout feature for sockets is great, but
the exception that is raised on timeout, socket.error,
is not very helpful.  It's not
possible to write code which catches and deals with
timeouts as opposed to the multitude of other socket
errors.

Even looking at the additional detail isn't helpful,
because you get errnos like EINPROGRESS or EAGAIN,
because the socket code doesn't deal with timeouts
explicitly when it selects.  Rather, it just lets the
internal_select() return, and then you get an error
when whatever was doing the waiting tries to do its
operation.

I propose that a new exception:

class socket.timeout(socket.error):
    pass

be created, and raised whenever the internal_select
times out (i.e. select() returns 0).

This lets applications catch socket.timeout
specifically if they want to, but also allows existing
code to catch socket.error and get all socket-related
exceptions.


----------------------------------------------------------------------

>Comment By: Raymond Hettinger (rhettinger)
Date: 2003-06-25 10:20

Message:
Logged In: YES 
user_id=80475

I agree this would be a useful API change.

Guido, do you concur?

----------------------------------------------------------------------

You can respond by visiting: 
https://sourceforge.net/tracker/?func=detail&atid=105470&aid=758239&group_id=5470