classification
Title: asyncio docs refer to wrong TimeoutError
Type: Stage:
Components: Documentation, Library (Lib) Versions: Python 3.4, Python 3.5
process
Status: closed Resolution: fixed
Dependencies: Superseder:
Assigned To: Nosy List: docs@python, giampaolo.rodola, gvanrossum, pitrou, python-dev, qmega, vstinner, yselivanov
Priority: normal Keywords:

Created on 2014-04-28 18:05 by qmega, last changed 2014-05-28 22:06 by vstinner. This issue is now closed.

Messages (5)
msg217390 - (view) Author: Philip Sequeira (qmega) Date: 2014-04-28 18:05
Example: https://docs.python.org/3.4/library/asyncio-task.html
TimeoutError is mentioned several times, and links to the OSError subclass. However, the actual TimeoutError raised by asyncio stuff is the one from concurrent.futures, which is not compatible. The docs as they are seem to suggest that something like "except TimeoutError" would be appropriate, when in fact that would not produce the expected behavior; "except asyncio.TimeoutError" is what you'd want.
msg217400 - (view) Author: Antoine Pitrou (pitrou) * (Python committer) Date: 2014-04-28 19:20
Gasp. Perhaps concurrent.futures.TimeoutError can inherit from the standard TimeoutError? The following patch doesn't seem to disrupt the test suite:

diff --git a/Lib/concurrent/futures/_base.py b/Lib/concurrent/futures/_base.py
--- a/Lib/concurrent/futures/_base.py
+++ b/Lib/concurrent/futures/_base.py
@@ -49,7 +49,7 @@ class CancelledError(Error):
     """The Future was cancelled."""
     pass
 
-class TimeoutError(Error):
+class TimeoutError(Error, TimeoutError):
     """The operation exceeded the given deadline."""
     pass
msg217402 - (view) Author: Guido van Rossum (gvanrossum) * (Python committer) Date: 2014-04-28 19:26
I considered this, and decided against unifying the two TimeoutErrors.

First the builtin TimeoutError is specifically a subclass of OSError representing the case where errno is ETIMEDOUT.  But asyncio.TimeoutError means nothing of the sort.

Second, the precedent is concurrent.futures.TimeoutError. The asyncio one is used under the same conditions as that one.

I think we should just update the links in the docs to be correct.
msg219310 - (view) Author: Roundup Robot (python-dev) (Python triager) Date: 2014-05-28 22:05
New changeset 6d90e8df01f4 by Victor Stinner in branch '3.4':
Issue #21376: document asyncio.TimeoutError
http://hg.python.org/cpython/rev/6d90e8df01f4

New changeset 03bb1077b362 by Victor Stinner in branch 'default':
(Merge 3.4) Issue #21376: document asyncio.TimeoutError
http://hg.python.org/cpython/rev/03bb1077b362
msg219311 - (view) Author: STINNER Victor (vstinner) * (Python committer) Date: 2014-05-28 22:06
Thanks for the report. In fact, asyncio.TimeoutError was not documented at all. It should now be fixed.
History
Date User Action Args
2014-05-28 22:06:16vstinnersetstatus: open -> closed
resolution: fixed
messages: + msg219311
2014-05-28 22:05:25python-devsetnosy: + python-dev
messages: + msg219310
2014-04-28 19:26:12gvanrossumsetnosy: gvanrossum, pitrou, vstinner, giampaolo.rodola, docs@python, yselivanov, qmega
messages: + msg217402
2014-04-28 19:20:55pitrousetnosy: + gvanrossum, pitrou, vstinner, giampaolo.rodola, yselivanov
messages: + msg217400

assignee: docs@python ->
components: + Library (Lib)
2014-04-28 18:05:57qmegacreate