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

handle KeyboardInterrupt with %gui asyncio #281

Merged
merged 4 commits into from
Nov 27, 2017

Conversation

minrk
Copy link
Member

@minrk minrk commented Nov 23, 2017

when interrupted, re-enter eventloop and don't close it (same as all the other eventloops)

Only close the eventloop when we are done for good AND we are responsible for running it.

Also avoid any cleanup when someone else is already running the eventloop (e.g. tornado 5).

closes #263

I'll try add a test for this before it's ready to merge.

when interrupted, re-enter eventloop and don't close it

only close the eventloop when we are done for good.

Also avoid any cleanup when someone else is already running the eventloop (e.g. tornado 5).
easier debugging when there are errors
@takluyver takluyver added this to the 4.7 milestone Nov 24, 2017
except KeyboardInterrupt:
continue
except Exception as e:
error = e
loop.run_until_complete(loop.shutdown_asyncgens())
Copy link
Member

Choose a reason for hiding this comment

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

The docs say that shutdown_asyncgens is new in 3.6, so this code might not work with 3.5? But maybe it's only on the abstract class that the method is new. This is already in the code, so I'm happy to merge this PR anyway, but it's worth checking.

@basnijholt
Copy link

@minrk thanks for this work. This fixes the problems (#263) I was having.

@takluyver takluyver merged commit 21882bd into ipython:master Nov 27, 2017
@minrk minrk deleted the asyncio-fix branch November 27, 2017 21:20
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.

Interrupting kernel from notebook closes asyncio event loop
3 participants