How to create a service in Python in Windows?

南楼画角 提交于 2020-01-06 18:13:40

问题


I have found http://code.activestate.com/recipes/576451-how-to-create-a-windows-service-in-python/

But that service does nothing. How can I use that service for running specific Python file?


回答1:


You can put your business code in SvcDoRun. The sample at your link just logs a message every three seconds. Just don't forget to check self.hWaitStop periodically.

Sometimes it is convenient to create a worker thread and do all work on that thread, or maybe start a child process. An additional complication in this case is that you have to think about synchronization.



来源:https://stackoverflow.com/questions/4436506/how-to-create-a-service-in-python-in-windows

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