[Python-ideas] Introduce BaseTimeoutError

Terry Reedy tjreedy at udel.edu
Sun Apr 2 19:08:44 EDT 2017


On 4/1/2017 3:27 PM, Ram Rachum wrote:
> Today I got burned because I had code that did this:
>
>     except TimeoutError:
>
> When it should have done this:
>
>     except socket.timeout:

Both are subclasses of OSError but mean different things.  TimeoutError 
means that something in 'your system' did not respond.  Socket.timeout 
means that a foreign system did not respond.  (I am leaving out a local 
socket connection.)  The latter can only happen with a socket call with 
timeouts enabled.  If it is possible for TimeoutError to also occur with 
a timeout-enabled socket call, then one might very well want to only 
catch one or catch them separately and respond differently.

> There's also another timeout error class in asyncio.

Which can only happen when using asyncio.

-1 on merging, +1 on staying with the current design.  What I write 
above is similar to Guido's explanation for asyncio.TimeoutError.

-- 
Terry Jan Reedy



More information about the Python-ideas mailing list