Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

stream() no longer suppresses CancelledError #156

Merged
merged 1 commit into from Aug 31, 2019

Conversation

lithp
Copy link
Contributor

@lithp lithp commented Aug 31, 2019

What was wrong?

Trinity had unclean shutdowns. A major contributor to them was lines like this:

ERROR  08-30 17:40:45               asyncio  Task exception was never retrieved
future: <Task finished coro=<<async_generator_asend without __name__>()> exception=StopAsyncIteration()>
StopAsyncIteration

The problem was happening within cancellable_wait. When it tries to cancel the pending tasks (line 142), it assumes that the tasks are successfully cancelled. Prior to this PR, Endpoint.stream() would catch the asyncio.CancelledError and then return. However, AsyncGenerators don't simply return, they signal the end of iteration by raising a StopAsyncIteration. So, the call to cancel() causes this coroutine to emit an exception, and python then complains that the exception is never retrieved.

How was it fixed?

This coroutine no longer catches CancelledError and instead propagates it to the calling coroutine, as the docs suggest every coroutine should.

Cute Animal Picture

bald-eagle

Copy link
Contributor

@cburgdorf cburgdorf left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

OMG! Epic! So happy we have someone on the team who really manages to make sense of all the asyncio mess 😂

@lithp lithp merged commit ac33faf into ethereum:master Aug 31, 2019
@lithp lithp deleted the lithp/dont-suppress-cancel branch August 31, 2019 06:06
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

None yet

3 participants