python asynchronous context manager

后端 未结 2 526
灰色年华
灰色年华 2021-01-20 11:33

In Python Lan Ref. 3.4.4, it is said that __aenter__() and __aexit__() must return awaitables. However, in the example async context manager, these

2条回答
  •  半阙折子戏
    2021-01-20 11:59

    The methods in this example do not return None. They are async functions, which automatically return (awaitable) asynchronous coroutines. This is similar to how generator functions return generator iterators, even though they usually have no return statement.

提交回复
热议问题