2đź‘Ť
The multiprocessing
module is designed as a drop-in replacement for the threading module. It’s designed to be used for the same kind of tasks you’d normally use threads for; speeding up execution by running against multiple cores, background polling, and any other task that you want running concurrently with some other task. It’s not designed to launch standalone daemon processes, so I don’t think it’s appropriate for your use-case.
The python-daemon
library is designed to “daemonize” the currently running Python process. I think what you want is to use the subprocess
library from your main process (the xmlrpc client) to launch your daemon process (the xmlrpc server), using subprocess.Popen
. Then, inside the daemon process, you can use the python-daemon
library to become a daemon.
So in the main process, something like this:
subprocess.Popen([my_daemon.py, "-o", "some_option"])
And in my_daemon.py
:
import daemon
...
def main():
# Do normal startup stuff
if __name__ == "__main__":
with daemon.DaemonContext(): # This makes the process a daemon
main()