You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.
Note: these values reflect the state of the issue at the time it was migrated and might not reflect the current state.
Show more details
assignee=Noneclosed_at=<Date2020-02-13.09:44:45.676>created_at=<Date2020-02-11.06:35:23.034>labels= ['3.7', '3.8', '3.9', 'release-blocker']
title='Regression: it should be possible to close async iterators multiple times'updated_at=<Date2020-02-13.09:44:45.676>user='https://github.com/njsmith'
In bpo-39386, the 'aclose' method for async generators was fixed so that the following broken code would correctly raise an error:
# -- bad code --asyncdefagen_fn():
awaitaclose_coro# Should raise RuntimeError:awaitaclose_coroasyncio.run(do_bad_thing())
However, the merged fix also broke the following correct code, which should *not* raise an error:
# -- good code --asyncdefagen_fn():
# Should *not* raise an error, but currently does in Python dev branches:awaitagen.aclose()
It's not supported to iterate the same coroutine object twice. However, making two *independent* calls to aclose should return two independent coroutine objects, and it should be legal to iterate over each object once.
This can also occur even if there's only a single call to 'aclose'. For example, this is the recommended idiom for making sure that an async generator correctly closes all its resources: