I would like to create optional asynchronious semaphore.
In case of asyncio.Semaphore
does not support None
values, i decided to create asyncio.Semaphore
, if connections limit is specified, else - some kind of dummy object
There is a contextlib.nullcontext
, but it supports only synchorious with
I`ve created my own dummy:
@contextlib.asynccontextmanager
async def asyncnullcontext():
yield None
It there any default asynchronious null context manager?
It there any default asynchronious null context manager?
You can use contextlib.AsyncExitStack()
.
ExitStack()
was similarly the way to create a quick-and-dirty null context manager before the introduction of nullcontext
.