如何在 运行 pdb 时退出散景应用程序?

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

我正在尝试调试散景服务器应用程序。目前我正在使用 pdb,但我无法退出 python 调试器。我在 运行 "q" 命令时收到一条错误消息。

'''
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
'''

我目前只是用它来规避这个问题,但这并不是一个真正方便的解决方案。

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

感谢您的帮助!

我在其他异步和网络应用程序中遇到过这种情况。我总是 ctrl-D 直到它最终退出。我能想到的唯一其他建议是 "hard" exit:

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