distributed: "Cannot start Bokeh server, port 8787 is already in use" while instantiating a Client

When using c = Client() from a script, I get this (on an 8 core machine):

bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use
bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use
bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use
bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use
bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use
bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use
bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use
bokeh.server.server - CRITICAL - Cannot start Bokeh server, port 8787 is already in use

and then it hangs.

Strange thing is, it does work OK from ipython or from a live python session. But if I create a script with the following code and try to run it (“python3 test.py”) it hangs:

from distributed import Client, local_client

client = Client()

Breaking with ctrl-c gives the following traceback:

Traceback (most recent call last):
  File "test_fib.py", line 3, in <module>
    client = Client()
Traceback (most recent call last):
  File "<string>", line 1, in <module>

Interrupted, shutting down  File "/usr/lib64/python3.5/multiprocessing/forkserver.py", line 164, in main
  File "/usr/lib/python3.5/site-packages/distributed/client.py", line 366, in __init__

    rfds = [key.fileobj for (key, events) in selector.select()]
  File "/usr/lib64/python3.5/selectors.py", line 441, in select
    self.start(timeout=timeout)
  File "/usr/lib/python3.5/site-packages/distributed/client.py", line 396, in start
    sync(self.loop, self._start, **kwargs)
  File "/usr/lib/python3.5/site-packages/distributed/utils.py", line 142, in sync
    e.wait(1000000)
    fd_event_list = self._epoll.poll(timeout, max_ev)
KeyboardInterrupt
  File "/usr/lib64/python3.5/threading.py", line 549, in wait
    signaled = self._cond.wait(timeout)
  File "/usr/lib64/python3.5/threading.py", line 297, in wait
    gotit = waiter.acquire(True, timeout)
KeyboardInterrupt
/usr/lib64/python3.5/multiprocessing/semaphore_tracker.py:129: UserWarning: semaphore_tracker: There appear to be 192 leaked semaphores to clean up at shutdown
  len(cache))

About this issue

  • Original URL
  • State: closed
  • Created 8 years ago
  • Comments: 17 (9 by maintainers)

Most upvoted comments

Also, a simple suggestion. Instead of:

from distributed import Client, local_client

client = Client()

Have you tried:

from distributed import Client, local_client

if __name__ == "__main__":
    client = Client()