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