-
Notifications
You must be signed in to change notification settings - Fork 5k
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
Asyncio error when opening notebooks #6164
Comments
Hi @nissankarkifm - thanks for opening this issue. I suspect this was introduced with the refactoring done in jupyter_client to use async methods for the synchronous On the bright side, this issue can be avoided by configuring Notebook to run with its
Or configure via the configuration file:
We should probably consider making this (async kernel management) the default at some point. This would require jupyter_client >= 6.x. Another option would be to cap jupyter_client < 7, but you'll miss out on features exposed in jupyter_client 7+. And a third option would be to switch to Jupyter Lab 3.x since it uses |
@kevin-bates Changing the config worked for me. Thanks! |
Which configuration file should that line go in? |
Referring to this document. https://jupyter-notebook.readthedocs.io/en/stable/config.html |
This issue has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/unable-to-run-jupyter-notebook-after-update-localhost/10764/2 |
Hello, For me, the notebook/kernel seems to be running but the throbber of the browser's tab is stuck spinning forever. Applying the fix above, solves both the error and the throbber. I think a new release should be done to fix this annoying issue. |
This issue has been mentioned on Jupyter Community Forum. There might be relevant details there: https://discourse.jupyter.org/t/unable-to-run-jupyter-notebook-after-update-localhost/10764/8 |
I'm experiencing the same issue. Using the configuration suggested by @kevin-bates works. (Python 3.9, OSX, Jupyter Notebook 6.4.4) Under what circumstances is the default configuration expected to work out of the box? I think this issue should be re-opened and only closed when running Jupyter notebook works right away without having to override this option. |
That's a fair comment. I think we have two options...
As I noted previously, this is getting into async details that I'm not adequately knowledgable about and perhaps David has some insights. For example, might jupyter/jupyter_client#697 have a positive impact on this? @NiklasRosenstein, to that last point, would you be able to install I'll go ahead and re-open this issue to your original point. |
I think option 1 is the most reasonable one. The error seems related to Tornado but I'm not sure how to fix it in jupyter_client (I don't think jupyter/jupyter_client#697 will fix it). |
Just as a side note: some extensions do not work yet for Jupyter Lab, e.g. RISE, making it worthwhile to keep Classic Notebooks working. |
Workaround to set Btw. this is my versions stack:
Windows 10 Are there plans to fix this, or we definitely should switch to Jupyter Lab and get used to it? |
RetroLab looks pretty much like Classic Notebook, hopefully you shouldn't be too bothered by the switch. |
I also encountered this issue when upgrading to
This lead me to the code in
We are only applying I make a quick change locally:
which applies This resolves the issue for me which I was easily able to reproduce. I also ran using the AsyncKernelManager both before and after this change and it ran fine. @kevin-bates @davidbrochart are you convinced by this explanation? Would you accept this as a PR to Jupyter client? |
@dleen - thank you for looking into this! I'm convinced, but that's not saying a whole lot. I would prefer hearing from @davidbrochart since he's got this stuff more wired than myself. Also note that the import statement was moved into its current position in jupyter/jupyter_client#665, so we should probably run this past @SylvainCorlay as well.
Turns out I don't have transfer rights to that repo, so this will remain here for now. |
Yeah I had noticed that and I wasn't sure if it was a functional change, or just a housekeeping/linting/style thing (no commit message). But the important thing is that it wasn't calling |
This is a fix for jupyter/notebook#6164 We are only applying `nest_asyncio` when `run_sync` has been called which means there could be tasks queued that are unpatched e.g. from the original issue: ``` <Task pending coro=<HTTP1ServerConnection._server_request_loop() running at /apps/python3/lib/python3.7/site-packages/tornado/http1connection.py:823> ``` which originates from Tornado. A similar issue was reported in `nest-asyncio`: erdewit/nest_asyncio#22 where the solution is to call `apply` on import so that unpatched tasks do not get created.
I opened a PR so we can continue the discussion there if it's better: jupyter/jupyter_client#718 |
Thanks David. We'll keep this issue open until we finalize things a bit. |
Thanks @dleen, I commented on your PR. But given that the future of the Classic Notebook is taking a direction that will probably solve this issue (by using RetroLab for Notebook v7), I'm not sure we should try and fix Notebook<7.0. |
Hmm. It will be several months before Notebook 7 is available given there are several "critical" extensions that require migration to the lab framework. In addition, there will be folks that never move to Notebook 7 because their "critical" extensions are not available. Are we convinced that moving the Another approach would be to apply the patch in That all said, I'd love to get @minrk's opinion on this. |
This is a fix for jupyter#6164 `nest_asyncio` must be applied before any async tasks have been created otherwise there could be tasks queued that are unpatched, and thus do not respect nested loops. An example of an unpatched task can be seen in the original issue: ``` <Task pending coro=<HTTP1ServerConnection._server_request_loop() running at /apps/python3/lib/python3.7/site-packages/tornado/http1connection.py:823> ``` which originates from Tornado. A similar issue was reported in `nest-asyncio`: erdewit/nest_asyncio#22 where the solution is to call `apply` on import so that unpatched tasks do not get created.
I followed @kevin-bates suggestion of applying the patch in an existing location where we patch asyncio I also explored if the notebooks own |
@davidbrochart I definitely agree with you here! I actually hit this issue while upgrading |
This is a fix for jupyter#6164 `nest_asyncio` must be applied before any async tasks have been created otherwise there could be tasks queued that are unpatched, and thus do not respect nested loops. An example of an unpatched task can be seen in the original issue: ``` <Task pending coro=<HTTP1ServerConnection._server_request_loop() running at /apps/python3/lib/python3.7/site-packages/tornado/http1connection.py:823> ``` which originates from Tornado. A similar issue was reported in `nest-asyncio`: erdewit/nest_asyncio#22 where the solution is to call `apply` on import so that unpatched tasks do not get created.
This is a fix for jupyter/notebook#6164 `nest_asyncio` must be applied before any async tasks have been created otherwise there could be tasks queued that are unpatched, and thus do not respect nested loops. An example of an unpatched task can be seen in the original issue: ``` <Task pending coro=<HTTP1ServerConnection._server_request_loop() running at /apps/python3/lib/python3.7/site-packages/tornado/http1connection.py:823> ``` which originates from Tornado. A similar issue was reported in `nest-asyncio`: erdewit/nest_asyncio#22 where the solution is to call `apply` on import so that unpatched tasks do not get created.
is it safe to use the workaround suggested above in this thread (i.e c.NotebookApp.kernel_manager_class = 'notebook.services.kernels.kernelmanager.AsyncMappingKernelManager')? my version stack: |
I'd like to know the same thing too. We are moving to JupyterLab soon in our online notebook service but in the meantime we are getting hit by this error in user sessions every now and then. |
Moving to asynchronous kernel management is probably safer than not since that's where the dev focus has been the last couple of years and JupyterServer has been using it since its inception (and on which Lab 3+ relies). So you're essentially moving your "experience" closer to where you want to be eventually. |
When I open a notebook from /tree, i get the following error in terminal:
Desktop (please complete the following information):
The text was updated successfully, but these errors were encountered: