Python - Best way to run a function in a "disconnected" process

I have a function f that I want to create in a separate process, which should have a life independent of the parent. What is the best way to do this?

I did not find a way to use multiprocessing.Process(target=f) in such a way that at some point it would not require a child to attach.

+5
source share
1 answer

I think you should try adding nohup to your script and use Popen ...
Something like that:

 import os, subprocess subprocess.Popen(['nohup', 'script.py'], stdout=devnull, stderr=devnull) 

If you put the function in script.py , it should work.

-1
source

Source: https://habr.com/ru/post/1237122/


All Articles