diff --git a/acapy_agent/utils/repeat.py b/acapy_agent/utils/repeat.py index 910960e5f2..3cab4c5327 100644 --- a/acapy_agent/utils/repeat.py +++ b/acapy_agent/utils/repeat.py @@ -1,7 +1,6 @@ """Utils for repeating tasks.""" import asyncio -from contextlib import asynccontextmanager from typing import Optional @@ -93,20 +92,5 @@ def __repr__(self) -> str: def _timeout_cm(duration: float): - """Compatibility wrapper for asyncio.timeout (Python <3.11).""" - if hasattr(asyncio, "timeout"): - return asyncio.timeout(duration) - - @asynccontextmanager - async def _timeout_gen(): - loop = asyncio.get_running_loop() - task = asyncio.current_task() - handle = loop.call_later(duration, task.cancel) - try: - yield - except asyncio.CancelledError as exc: - raise asyncio.TimeoutError from exc - finally: - handle.cancel() - - return _timeout_gen() + """Async context manager that times out after duration (asyncio.timeout).""" + return asyncio.timeout(duration)