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.

classification
Title: socket timeout exception unhelpful
Type: Stage:
Components: Library (Lib) Versions: Python 2.3
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: rhettinger Nosy List: gvanrossum, rhettinger, rthalley
Priority: normal Keywords:

Created on 2003-06-21 01:27 by rthalley, last changed 2022-04-10 16:09 by admin. This issue is now closed.

Messages (4)
msg16560 - (view) Author: Bob Halley (rthalley) Date: 2003-06-21 01:27
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.
msg16561 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-25 15:20
Logged In: YES 
user_id=80475

I agree this would be a useful API change.

Guido, do you concur?
msg16562 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2003-06-27 10:55
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).
msg16563 - (view) Author: Raymond Hettinger (rhettinger) * (Python committer) Date: 2003-06-29 03:35
Logged In: YES 
user_id=80475

Applied patch #760257.
Closing bug.
History
Date User Action Args
2022-04-10 16:09:22adminsetgithub: 38695
2003-06-21 01:27:13rthalleycreate