Chapter 3. Data model 44 The Python Language Reference, Release 3.9.5 Changed in version 3.7: Prior to Python 3.7,$_{__aiter__}$ could return an awaitable that would resolve to an asyn- chronous iterator . An asynchronous context manager is a context manager that is able to suspend execution in its$_{__aenter__}$ and __aexit__ methods. Asynchronous context managers can be used in an async with statement. An example of an asynchronous context manager class: New in version 3.5. Semantically similar to$_{__enter__()}$ , the only difference being that it must return an awaitable . Semantically similar to __exit__() , the only difference being that it must return an awaitable . object. __aexit__ ( self , exc_type , exc_value , traceback$_{)}$ object. __aenter__ ( self ) classAsyncContextManager : async def __aenter__ (self): await log( 'entering context') async def __aexit__ (self, exc_type, exc, tb): await log( 'exiting context') 3.4.4 Asynchronous Context Managers Starting with Python 3.7,$_{__aiter__}$ must return an asynchronous iterator object. Returning anything else will result in a TypeError error.