Skip to content

Commit

Permalink
remove timeout management
Browse files Browse the repository at this point in the history
timeout parameters are useless, this is all managed by asyncio directly.
For legacy purposes, a @legacy_timeout decorator adds the legacy timeout
parameters and hands them over to asyncio.wait_for.
  • Loading branch information
Martin Teichmann committed Jan 6, 2024
1 parent 2874e58 commit 24f718e
Show file tree
Hide file tree
Showing 5 changed files with 65 additions and 157 deletions.
8 changes: 3 additions & 5 deletions aiormq/base.py
Expand Up @@ -9,7 +9,7 @@
AbstractBase, AbstractFutureStore, CoroutineType, ExceptionType, TaskType,
TaskWrapper, TimeoutType,
)
from .tools import Countdown, shield
from .tools import legacy_timeout, shield


T = TypeVar("T")
Expand Down Expand Up @@ -130,15 +130,13 @@ async def __closer(self, exc: Optional[ExceptionType]) -> None:
with suppress(Exception):
await self._cancel_tasks(exc)

@legacy_timeout
async def close(
self, exc: Optional[ExceptionType] = asyncio.CancelledError,
timeout: TimeoutType = None,
) -> None:
if self.is_closed:
return None

countdown = Countdown(timeout)
await countdown(self.__closer(exc))
await self.__closer(exc)

def __repr__(self) -> str:
cls_name = self.__class__.__name__
Expand Down

0 comments on commit 24f718e

Please sign in to comment.