Search code examples
bokehexitpdb

How to quit out of a bokeh app when running pdb?


I am trying to debug a bokeh server app. Currently I am working with pdb but I am not able to quit the python debugger. I get an error message when running the "q" command.

'''
2019-05-10 22:08:08,123 WebSocket connection opened
2019-05-10 22:08:08,124 ServerConnection created
2019-05-10 22:08:08,182 Error thrown from periodic callback:
2019-05-10 22:08:08,192 Traceback (most recent call last):
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tornado/gen.py", line 883, in callback
    result_list.append(f.result())
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/tornado/gen.py", line 1147, in run
    yielded = self.gen.send(value)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bokeh/server/session.py", line 70, in _needs_document_lock_wrapper
    result = yield yield_for_all_futures(func(self, *args, **kwargs))
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bokeh/server/session.py", line 191, in with_document_locked
    return func(*args, **kwargs)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bokeh/document/document.py", line 1126, in wrapper
    return doc._with_self_as_curdoc(invoke)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bokeh/document/document.py", line 1112, in _with_self_as_curdoc
    return f()
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/site-packages/bokeh/document/document.py", line 1125, in invoke
    return f(*args, **kwargs)
  File "/Users/user/git/my_app/my_app/smooth_simulation.py", line 399, in animate
    filter.tree_filtering(z_list, R_list, t)
  File "/Users/user/git/my_app/my_app/filter.py", line 489, in tree_filtering
    max_node = self.leave_list[np.argmax([n.w for n in self.leave_list])]
  File "/Users/user/git/my_app/my_app/filter.py", line 489, in tree_filtering
    max_node = self.leave_list[np.argmax([n.w for n in self.leave_list])]
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/bdb.py", line 48, in trace_dispatch
    return self.dispatch_line(frame)
  File "/Library/Frameworks/Python.framework/Versions/3.6/lib/python3.6/bdb.py", line 67, in dispatch_line
    if self.quitting: raise BdbQuit
bdb.BdbQuit
'''

I am currently just using this to circumvent the issue, but that is not really a convenient solution.

'''
import signal; import os; os.kill(os.getpid(), signal.SIGKILL)
'''

Thanks for the help!


Solution

  • I have experienced this with other async and network apps. I always just ctrl-D until it eventually exits. The only other suggestion I can think of is a "hard" exit:

    import os; os._exit(0)  # notice the underscore