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

Use tornado 6.2's PeriodicCallback in restarter #822

Merged
merged 5 commits into from
Aug 19, 2022

Conversation

vidartf
Copy link
Contributor

@vidartf vidartf commented Aug 18, 2022

Since tornado 6.2, the PeriodicCallback will now await any callbacks that are awaitable (tornadoweb/tornado#2924). So we no longer need to wrap the async restarter's poll method in a run_sync call. This allows us to not depend on nest_asyncio with the default configuration of jupyter client, so we can avoid some of its pitfalls (e.g. jupyterlab/jupyterlab#11934).

vidartf and others added 4 commits August 18, 2022 18:05
Since it will now await any callbacks that are awaitable, we no longer need to wrap it in a `run_sync` call.
@vidartf
Copy link
Contributor Author

vidartf commented Aug 18, 2022

Note that this by itself will likely not fix the issue in jupyterlab/jupyterlab#11934 for all users. Anyone who uses any of our sync classes might still be experiencing issues. Or it could be that the issue only appears for PeriodicCallback, I would have to dig a little deeper into the logic.

To clarify that issue: If we call nest_asyncio.patch() while we are already inside a asyncio.base_events._run_once() call, and the instance has more items in its queue still left to process, then there is a risk (race?) that the run_until_complete inside run_sync modifies the queue of the event loop. That will cause an unrecoverable error in asyncio ("can't pop from deque").

@vidartf
Copy link
Contributor Author

vidartf commented Aug 18, 2022

I see that the xeus kernel test in the downstream check fails on a run_sync call. Maybe it is same root cause of that issue?
EDIT: I see this is failing on master as well, and seems unrelated

@blink1073
Copy link
Contributor

Let's see if we can get all green without xeus-cling.

Copy link
Contributor

@blink1073 blink1073 left a comment

Choose a reason for hiding this comment

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

LGTM, thanks for working on this!

@blink1073 blink1073 merged commit d64444d into jupyter:main Aug 19, 2022
@vidartf vidartf deleted the async-restarter branch August 19, 2022 17:25
@vidartf
Copy link
Contributor Author

vidartf commented Aug 25, 2022

Is it okay to release this as a patch release when it bumps the tornado dependency version?

@blink1073
Copy link
Contributor

Yeah, let's try that, releasing now.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants