我想创建可选的异步信号量。
在asyncio.Semaphore不支持None值的情况下,我决定创建asyncio.Semaphore,如果指定了连接限制,否则 - 某种虚拟对象
有一个contextlib.nullcontext,但它只支持同步with
我已经创建了自己的虚拟对象:
@contextlib.asynccontextmanager
async def asyncnullcontext():
yield None
Run Code Online (Sandbox Code Playgroud)
它有任何默认的异步空上下文管理器吗?