JacquesB JacquesB - 1 month ago 9
Python Question

Starting a separate process

I want a script to start a new process, such that the new process continues running after the initial script exits. I expected that I could use

multiprocessing.Process
to start a new process, and set
daemon=True
so that the main script may exit while the created process continues running.

But it seems that the second process is silently terminated when the main script exits. Is this expected behavior, or am I doing something wrong?

Answer Source

From the Python docs:

When a process exits, it attempts to terminate all of its daemonic child processes.

This is the expected behavior.