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

SourceForge.net noreply@sourceforge.net
Sat, 28 Jun 2003 20:35:44 -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: Closed
>Resolution: Fixed
Priority: 5
Submitted By: Bob Halley (rthalley)
Assigned to: Raymond Hettinger (rhettinger)
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-28 22:35

Message:
Logged In: YES 
user_id=80475

Applied patch #760257.
Closing bug.

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

Comment By: Guido van Rossum (gvanrossum)
Date: 2003-06-27 05:55

Message:
Logged In: YES 
user_id=6380

I agree too. Raymond, can you prepare a minimal patch?

Given my location at EuroPython, an email with the patch
would be appreciated (in addition to SF upload).

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

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