jupyter / atom-notebook

[Deprecated] Jupyter Notebook, but inside Atom.
MIT License
306 stars 48 forks source link

"Address already in use" in inspector when Jupyter is already running #28

Closed amoeba closed 8 years ago

amoeba commented 8 years ago

Really excited to see this package, thanks for putting it together!

I opened an ipynb file and got red error pop about an error. Looking at the inspector console, I saw:

kernelGateway.stderr Traceback (most recent call last):
  File "/usr/local/bin/jupyter-kernelgateway", line 7, in <module>
    kernel_gateway.launch_instance()
  File "/usr/local/lib/python3.5/site-packages/jupyter_core/application.py", line 267, in launch_instance
    return super(JupyterApp, cls).launch_instance(argv=argv, **kwargs)
  File "/usr/local/lib/python3.5/site-packages/traitlets/config/application.py", line 591, in launch_instance
    app.initialize(argv)
  File "/usr/local/lib/python3.5/site-packages/kernel_gateway/gatewayapp.py", line 203, in initialize
    self.init_http_server()
  File "/usr/local/lib/python3.5/site-packages/kernel_gateway/gatewayapp.py", line 285, in init_http_server
    self.http_server.listen(self.port, self.ip)
  File "/usr/local/lib/python3.5/site-packages/tornado/tcpserver.py", line 126, in listen
    sockets = bind_sockets(port, address=address)
  File "/usr/local/lib/python3.5/site-packages/tornado/netutil.py", line 196, in bind_sockets
    sock.bind(sockaddr)
OSError: [Errno 48] Address already in use

I then shut down a local instance of Jupyter already running on my machine, closed and re-opened the previous ipynb file from before and the file loaded without error and I see this in my inspector console:

kernelGateway.stderr [KernelGatewayApp] The Jupyter Kernel Gateway is running at: http://localhost
Kernel:  python3
Starting WebSocket: ws://localhost:8888/api/kernels/8f416440-3976-4067-ac88-c119e6070800

Which looks good. Maybe it would be good to catch this state and provide a more useful error message to the user?

gnestor commented 8 years ago

Related https://github.com/indexzero/node-portfinder/issues/13

gnestor commented 8 years ago

Fixed on 0.0.8 with https://github.com/jupyter/atom-notebook/commit/e0e4d413265dc725ae2ce96b5bef74b06bd5fbe1

amoeba commented 8 years ago

Excellent, thanks for the quick fix.