在 Python Lan 参考文献中。3.4.4,据说__aenter__()
并且__aexit__()
必须返回awaitables。但是,在示例异步上下文管理器中,这两个方法返回 None:
class AsyncContextManager:
async def __aenter__(self):
await log('entering context')
async def __aexit__(self, exc_type, exc, tb):
await log('exiting context')
Run Code Online (Sandbox Code Playgroud)
这段代码正确吗?