asyncx.acontext

asyncx.acontext(coro: Awaitable[TReturn]) AsyncContextManager[asyncio.Task[TReturn]][source]
asyncx.acontext(future: TFuture) AsyncContextManager[TFuture]

Creates an async context manager that cancels a given awaitable in __aexit__.

Arg:

awaitable: A target awaitable object

Returns

An async context manager that creates a future and cancels it of a given awaitable.