8.20. AsyncIO Context Manager

  • __aenter__

  • __aexit__

8.20.1. Example

>>> class AsyncContextManager:
...     async def __aenter__(self):
...         await print('entering context')
...
...     async def __aexit__(self, exc_type, exc, tb):
...         await print('exiting context')