averbis / IRuta

A UIMA Ruta kernel for Jupyter Notebook.
Apache License 2.0
7 stars 1 forks source link

SoS notebook kernel restart fails because socket address already in use in Jupyter-Notebook #8

Open DavidHuebner opened 3 years ago

DavidHuebner commented 3 years ago

Describe the bug In jupyter-notebook, a kernel restart of a Notebook that uses the sos-kernel (i.e. those notebooks that contain Python AND Ruta code), fails with the following error.

[I 15:34:13.004 NotebookApp] Restoring connection for b0ce13e9-f374-4227-8fb7-9d147ea3f178:696ef6b3b33746d89f672c689160fccc
Traceback (most recent call last):
  File "/usr/local/lib/python3.8/runpy.py", line 194, in _run_module_as_main
    return _run_code(code, main_globals, None,
  File "/usr/local/lib/python3.8/runpy.py", line 87, in _run_code
    exec(code, run_globals)
  File "/usr/local/lib/python3.8/site-packages/sos_notebook/kernel.py", line 1956, in <module>
    IPKernelApp.launch_instance(kernel_class=SoS_Kernel)
  File "/usr/local/lib/python3.8/site-packages/traitlets/config/application.py", line 844, in launch_instance
    app.initialize(argv)
  File "/usr/local/lib/python3.8/site-packages/traitlets/config/application.py", line 87, in inner
    return method(app, *args, **kwargs)
  File "/usr/local/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 567, in initialize
    self.init_sockets()
  File "/usr/local/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 271, in init_sockets
    self.shell_port = self._bind_socket(self.shell_socket, self.shell_port)
  File "/usr/local/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 218, in _bind_socket
    return self._try_bind_socket(s, port)
  File "/usr/local/lib/python3.8/site-packages/ipykernel/kernelapp.py", line 194, in _try_bind_socket
    s.bind("tcp://%s:%i" % (self.ip, port))
  File "/usr/local/lib/python3.8/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

Afterwards, if the dead kernel is restarted, it works.

To Reproduce Steps to reproduce:

  1. Copy https://github.com/averbis/IRuta
  2. Build the docker image: docker build -t iruta
  3. Run the docker image: docker run -p 8888:8888 iruta
  4. Open the notebook Notebook [IRuta, IPython] - How to combine Ruta and Python
  5. Restart the notebook.

Steps to solve the problem It seems that there is a bug in sos-notebook. I made a ticket there: https://github.com/vatlab/sos-notebook/issues/317

Alternatively, it seems that this error does not exist in JupyterLab.

Versions