How do I implement a simple cross platform Python daemon?

前端 未结 5 1580
执笔经年
执笔经年 2021-01-31 10:27

I would like to have my Python program run in the background as a daemon, on either Windows or Unix. I see that the python-daemon package is for Unix only; is there an alternati

5条回答
  •  被撕碎了的回忆
    2021-01-31 10:51

    Two options come to mind:

    1. Port your program into a windows service. You can probably share much of your code between the two implementations.

    2. Does your program really use any daemon functionality? If not, you rewrite it as a simple server that runs in the background, manages communications through sockets, and perform its tasks. It will probably consume more system resources than a daemon would, but it would be quote platform independent.

提交回复
热议问题