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

Clean up the pending task #697

Merged
merged 3 commits into from
Sep 28, 2021
Merged
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
7 changes: 6 additions & 1 deletion jupyter_client/utils.py
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,12 @@ def wrapped(*args, **kwargs):
import nest_asyncio # type: ignore

nest_asyncio.apply(loop)
return loop.run_until_complete(coro(*args, **kwargs))
future = asyncio.ensure_future(coro(*args, **kwargs))
try:
return loop.run_until_complete(future)
except KeyboardInterrupt:
future.cancel()
raise
Copy link
Member

Choose a reason for hiding this comment

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

Maybe we want to handle any kind of exception?

Suggested change
except KeyboardInterrupt:
future.cancel()
raise
except BaseException as e:
future.cancel()
raise e

Copy link
Contributor Author

Choose a reason for hiding this comment

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

I agree with your suggestion.


wrapped.__doc__ = coro.__doc__
return wrapped
Expand Down