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

SoS Kernel restart fails due to zmq.error.ZMQError: Address already in use #317

Open
DavidHuebner opened this issue May 17, 2021 · 4 comments
Assignees

Comments

@DavidHuebner
Copy link

Problem

Restarting a Jupyter Notebook with SoS kernel crashes each time with the following error logs:

Traceback (most recent call last):
File "/opt/conda/lib/python3.9/runpy.py", line 197, in _run_module_as_main
return _run_code(code, main_globals, None,
File "/opt/conda/lib/python3.9/runpy.py", line 87, in _run_code
exec(code, run_globals)
File "/opt/conda/lib/python3.9/site-packages/sos_notebook/kernel.py", line 1956, in
IPKernelApp.launch_instance(kernel_class=SoS_Kernel)
File "/opt/conda/lib/python3.9/site-packages/traitlets/config/application.py", line 844, in launch_instance
app.initialize(argv)
File "/opt/conda/lib/python3.9/site-packages/traitlets/config/application.py", line 87, in inner
return method(app, *args, **kwargs)
File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelapp.py", line 567, in initialize
self.init_sockets()
File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelapp.py", line 271, in init_sockets
self.shell_port = self._bind_socket(self.shell_socket, self.shell_port)
File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelapp.py", line 218, in _bind_socket
return self._try_bind_socket(s, port)
File "/opt/conda/lib/python3.9/site-packages/ipykernel/kernelapp.py", line 194, in _try_bind_socket
s.bind("tcp://%s:%i" % (self.ip, port))
File "/opt/conda/lib/python3.9/site-packages/zmq/sugar/socket.py", line 172, in bind
super().bind(addr)
File "zmq/backend/cython/socket.pyx", line 540, in zmq.backend.cython.socket.Socket.bind
File "zmq/backend/cython/checkrc.pxd", line 28, in zmq.backend.cython.checkrc._check_rc
zmq.error.ZMQError: Address already in use

It tries restarting the kernel for five times, then the SoS Kernel is dead with the following log and screenshot.

Future exception was never retrieved
future: <Future finished exception=RuntimeError('Restart failed')>
RuntimeError: Restart failed

image

Clicking on "Try Restarting Now" actually work, but this should not be the "appropriate" way to restart the kernel and causes a bad user experience.

Steps to reproduce the error

I created a very simple Dockerfile to reproduce the error.

FROM jupyter/base-notebook

# Install python dependencies
RUN pip3 install sos-notebook==0.22.4
RUN pip3 install sos==0.22.4
RUN python -m sos_notebook.install

USER jovyan
CMD ["jupyter", "notebook", "--ip", "0.0.0.0"]
  1. Put the above content into a Dockerfile
  2. Open a terminal in that directory and execute docker build . -t sos-test
  3. Run the docker container with docker run -p 8888:8888 sos-test
  4. Open the Jupyter Notebook
  5. Create a new Notebook with SoS Kernel
  6. Execute any python command in that notebook, e.g. print("hi")
  7. Restart the kernel
@BoPeng
Copy link
Contributor

BoPeng commented May 17, 2021

This looks scary and might be caused by recent releases of jupyter notebook and/or python. Anyway, the focus of development of the sos notebook project has long been moved to jupyterlab. Is there any reason you cannot use the jupyterlab frontend?

@BoPeng
Copy link
Contributor

BoPeng commented May 17, 2021

I can confirm this bug with the official sos-notebook docker image, and also confirm that the jupyterlab frontend is immune from this problem.

@BoPeng BoPeng self-assigned this May 17, 2021
@BoPeng BoPeng added the bug label May 17, 2021
@BoPeng
Copy link
Contributor

BoPeng commented May 17, 2021

I spent a few hours on this issue but could not find a solution. I will have to revisit this issue later.

@DavidHuebner
Copy link
Author

This looks scary and might be caused by recent releases of jupyter notebook and/or python. Anyway, the focus of development of the sos notebook project has long been moved to jupyterlab. Is there any reason you cannot use the jupyterlab frontend?

Thanks for your quick reply and investigation. We are developing a custom Jupyter kernel and want to provide a Binder link. The main reason why we are not using the jupyterlab frontend is because we found the integration with Binder to be very difficult, especially when installing the required jupyterlab extensions. We might try that route again.

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

No branches or pull requests

2 participants