File tree Expand file tree Collapse file tree 1 file changed +2
-18
lines changed
Expand file tree Collapse file tree 1 file changed +2
-18
lines changed Original file line number Diff line number Diff line change 11"""Utils for repeating tasks."""
22
33import asyncio
4- from contextlib import asynccontextmanager
54from typing import Optional
65
76
@@ -93,20 +92,5 @@ def __repr__(self) -> str:
9392
9493
9594def _timeout_cm (duration : float ):
96- """Compatibility wrapper for asyncio.timeout (Python <3.11)."""
97- if hasattr (asyncio , "timeout" ):
98- return asyncio .timeout (duration )
99-
100- @asynccontextmanager
101- async def _timeout_gen ():
102- loop = asyncio .get_running_loop ()
103- task = asyncio .current_task ()
104- handle = loop .call_later (duration , task .cancel )
105- try :
106- yield
107- except asyncio .CancelledError as exc :
108- raise asyncio .TimeoutError from exc
109- finally :
110- handle .cancel ()
111-
112- return _timeout_gen ()
95+ """Async context manager that times out after duration (asyncio.timeout)."""
96+ return asyncio .timeout (duration )
You can’t perform that action at this time.
0 commit comments