如何停止bokeh服务器? [英] How to stop bokeh server?
问题描述
我确实使用bokeh来实时绘制本地LAN上的传感器数据.Bokeh是从我的python应用程序中使用popen启动的: Popen("bokeh serve --host = localhost:5006 --host = 192.168.8.100:5006",shell = True)
I do use bokeh to plot sensor data live on the local LAN. Bokeh is started from within my python application using popen: Popen("bokeh serve --host=localhost:5006 --host=192.168.8.100:5006", shell=True)
我想从应用程序中关闭bokeh服务器.但是,我在文档中找不到任何内容.同样, bokeh服务--help
也没有给出任何提示.
I would like to close bokeh server from within the application. However, I cannot find anything in the documentation. Also bokeh serve --help
does not give any hint how to do that.
基于公认的答案,我想出了以下解决方案:
based on the accepted answer I came up with following solution:
self.bokeh_serve = subprocess.Popen(shlex.split(command),
shell=False, stdout=subprocess.PIPE)
我使用 self.bokeh_serve.kill()
结束了该过程.也许 .terminate()
会更好.我会尝试的.
I used self.bokeh_serve.kill()
for ending the process. Maybe .terminate()
would be better. I will try it.
推荐答案
在不了解bokeh且假设您使用Python> = 3.2或Linux的情况下,您可以尝试使用 SIGTERM
, SIGINT
或 SIGHUP
,使用 os.kill()
与 Popen.send_signal()
.如果bokeh具有适当的信号处理程序,它甚至可以干净地关闭.
Without knowing bokeh and assuming that you use Python >= 3.2 or Linux, you could try to kill the process with SIGTERM
, SIGINT
or SIGHUP
, using os.kill()
with Popen.pid
or even better Popen.send_signal()
. If bokeh has proper signal handlers, it will even shutdown cleanly.
但是,最好使用选项 shell = False
,因为使用 shell = True
时,信号会发送到Shell,而不是实际的进程.
However, you may be better off using the option shell=False
, because with shell=True
, the signal is sent to the shell instead of the actual process.
这篇关于如何停止bokeh服务器?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!