How do you create a daemon in Python?

后端 未结 16 2032
轻奢々
轻奢々 2020-11-22 01:55

Searching on Google reveals x2 code snippets. The first result is to this code recipe which has a lot of documentation and explanation, along with some useful discussion und

16条回答
  •  小鲜肉
    小鲜肉 (楼主)
    2020-11-22 02:34

    80% of the time, when folks say "daemon", they only want a server. Since the question is perfectly unclear on this point, it's hard to say what the possible domain of answers could be. Since a server is adequate, start there. If an actual "daemon" is actually needed (this is rare), read up on nohup as a way to daemonize a server.

    Until such time as an actual daemon is actually required, just write a simple server.

    Also look at the WSGI reference implementation.

    Also look at the Simple HTTP Server.

    "Are there any additional things that need to be considered? " Yes. About a million things. What protocol? How many requests? How long to service each request? How frequently will they arrive? Will you use a dedicated process? Threads? Subprocesses? Writing a daemon is a big job.

提交回复
热议问题