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

Mashing Ctrl-C results in an UnboundLocalError #439

Closed
ianhi opened this issue Mar 8, 2021 · 1 comment
Closed

Mashing Ctrl-C results in an UnboundLocalError #439

ianhi opened this issue Mar 8, 2021 · 1 comment
Labels

Comments

@ianhi
Copy link

ianhi commented Mar 8, 2021

I have always shut down jupyter applications by hitting Ctrl-C twice. For a long time this seemed to work fine, however recently I've noticed that doing so so results is this error:

Traceback (most recent call last):
  File "/home/ian/mambaforge/envs/micro/bin/jupyter-lab", line 10, in <module>
    sys.exit(main())
  File "/home/ian/mambaforge/envs/micro/lib/python3.8/site-packages/jupyter_server/extension/application.py", line 520, in launch_instance
    serverapp.start()
  File "/home/ian/mambaforge/envs/micro/lib/python3.8/site-packages/jupyter_server/serverapp.py", line 2101, in start
    self.start_ioloop()
  File "/home/ian/mambaforge/envs/micro/lib/python3.8/site-packages/jupyter_server/serverapp.py", line 2093, in start_ioloop
    self._cleanup()
  File "/home/ian/mambaforge/envs/micro/lib/python3.8/site-packages/jupyter_server/serverapp.py", line 2078, in _cleanup
    self.cleanup_kernels()
  File "/home/ian/mambaforge/envs/micro/lib/python3.8/site-packages/jupyter_server/serverapp.py", line 1847, in cleanup_kernels
    run_sync(self.kernel_manager.shutdown_all())
  File "/home/ian/mambaforge/envs/micro/lib/python3.8/site-packages/jupyter_server/utils.py", line 228, in run_sync
    return wrapped()
  File "/home/ian/mambaforge/envs/micro/lib/python3.8/site-packages/jupyter_server/utils.py", line 227, in wrapped
    return result
UnboundLocalError: local variable 'result' referenced before assignment

Reproduce

I'm not sure the exact situation that reproduces this. Just opening jupyterlab is inadequate, but this tends to happen to me after a day of work with multiple open notebooks. However, it is clear that this is a risk as there is an if without a corresponding else in the code:

result = loop.run_until_complete(maybe_async)
except RuntimeError as e:
if str(e) == 'This event loop is already running':
# just return a Future, hoping that it will be awaited
result = asyncio.ensure_future(maybe_async)
return result

Environment:

conda list | grep jupyter

jupyter-packaging         0.7.12             pyhd8ed1ab_0    conda-forge
jupyter_client            6.1.11             pyhd8ed1ab_1    conda-forge
jupyter_core              4.7.1            py38h578d9bd_0    conda-forge
jupyter_server            1.4.1            py38h578d9bd_0    conda-forge
jupyterlab                3.0.9              pyhd8ed1ab_0    conda-forge
jupyterlab-code-formatter 1.4.4                    pypi_0    pypi
jupyterlab-vim            0.13.4                   pypi_0    pypi
jupyterlab-vimrc          0.5.2                    pypi_0    pypi
jupyterlab_pygments       0.1.2              pyh9f0ad1d_0    conda-forge
jupyterlab_server         2.3.0              pyhd8ed1ab_0    conda-forge
jupyterlab_widgets        1.0.0              pyhd8ed1ab_1    conda-forge
Zsailer added a commit to Zsailer/jupyter_server that referenced this issue Nov 18, 2022
* Bump to 0.23.6

* cleanup changelog
@blink1073 blink1073 added the bug label Jan 8, 2023
@blink1073
Copy link
Contributor

This code as moved to jupyter_core and now returns in the referenced if block, closing as fixed.

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

No branches or pull requests

2 participants