Search code examples
pythonrestforkwsgigevent

How are daemon processes started in Python?


I want to start two daemon process in python like following code:

daemon_main = DaemonImplMain()
daemon_check = DaemonImplCheck()
pid = os.fork()
if pid:
    daemon_main.start()
else:
    daemon_check.start()

in this code , daemon_main is a http server with wsgi, daemon_check is a check process. But the daemon_main cannot accept request when i run this code.


Solution

  • Do DaemonImplMain and DaemonImplCheck inherit from threading.Thread? If so, then you can set the daemon to true before starting the threads.

    For eg.

    daemon_main.daemon = True
    daemon_main.start()
    

    Same goes for daemon_check