python3.7+ 中是否有任何默认的异步空上下文管理器?

It there any default asynchronious null context manager in python3.7+?

我想创建可选的异步信号量。
如果 asyncio.Semaphore 不支持 None 值,我决定创建 asyncio.Semaphore,如果指定了连接限制,否则 - 某种虚拟对象
有一个contextlib.nullcontext,但是只支持同步with
我创建了自己的假人:

@contextlib.asynccontextmanager
async def asyncnullcontext():
    yield None

是否有任何默认的异步空上下文管理器?

It there any default asynchronious null context manager?

您可以使用 contextlib.AsyncExitStack().

ExitStack() 类似于在引入 nullcontext.

之前创建快速而肮脏的空上下文管理器的方法