Starting python bottle in a thread/Process and another daemon next to it

寵の児 提交于 2019-12-04 21:37:01

There are several issues:

  • you call run() in the main thread. You should pass arguments in args instead:

    Process(target=bottle.run, kwargs=dict(host='0.0.0.0', port=8080))
    
  • you call t.join() which blocks until t process ends before h.start(). Join after all processes are started instead

  • bottle, tftpy might not be compatible with multiprocessing module. You could try subprocess module if so

Well, I am not sure if I understood what you are trying to accomplish but if I were in your place I would try to use the python-daemon package

I think that both bottle and TFTP could be daemonized. As you are only in search for a simple test I guess that the examples given in the python-daemon webpage would be enough.

If you really like the idea of going daemonizing things, I would suggest also that you search about the proper daemonizing approach for your platform as this way you have several facilities to manage your daemon by making them more alike to the ones found in your OS.

For some simple examples: http://troydhanson.wordpress.com/2012/08/21/minimal-sysvinit-launchd-and-upstart/

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!