asyncio.timeout could be used as a decorator #100283
Labels
expert-asyncio
pending
The issue will be closed if no feedback is provided
type-feature
A feature request or enhancement
alex-janss commentedDec 15, 2022
Feature or enhancement
Allow
asyncio.timeout
andasyncio.timeout_at
to also be used as decorators.Pitch
It would be convenient to be able to wrap coroutines with timeouts:
This reduces nesting and makes the timeout more visible, an argument made here: contextlib.ContextDecorator. Note that this functionality is included by default for any context managers created with
contextlib
, and could be easily implemented by subclassingcontextlib.AsyncContextDecorator
.The text was updated successfully, but these errors were encountered: