-
-
Notifications
You must be signed in to change notification settings - Fork 33.7k
Closed
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir
Description
Documentation
The documentation page about asyncio.wait_for() function says that:
If a timeout occurs, it cancels the task and raises TimeoutError.
The TimeoutError hyperlink leads to the built-in exception "TimeoutError", which would lead any sane user to think that asyncio.wait_for() raises builtin TimeoutError.
However, it doesn't:
#!/usr/bin/env python3
import asyncio
async def main():
try:
await asyncio.wait_for(asyncio.sleep(100), timeout=1)
except TimeoutError:
print('timeout error')
except Exception as exc:
print('not a timeout error:', type(exc))
asyncio.run(main())The above program prints:
not a timeout error: <class 'asyncio.exceptions.TimeoutError'>
Documentation should be changed to reflect what really happens in Python.
Linked PRs
Metadata
Metadata
Assignees
Labels
docsDocumentation in the Doc dirDocumentation in the Doc dir