Important rule: Different coroutines own different contexts.
- The
example1.py
runs one coroutine with async_generator, theasync_generator.__anext__
method runs in same context and thus it works find. - The
example2.py
produces two coroutines with the same async_generator, theasync_generator.__anext__
method runs in different contexts and thus it raises an ValueError exception.