How to let the child process live when parent process exited?

后端 未结 2 736
一整个雨季
一整个雨季 2020-12-10 06:34

I want to use multiprocessing module to complete this.

when I do this, like:

    $ python my_process.py

I start a pare

相关标签:
2条回答
  • 2020-12-10 06:59

    Here's one way to achieve an independent child process that does not exit when __main__ exits. It uses the os._exit() tip mentioned above by @WKPlus.

    Is there a way to detach matplotlib plots so that the computation can continue?

    0 讨论(0)
  • 2020-12-10 07:15

    A trick: call os._exit to make parent process exit, in this way daemonic child processes will not be killed.

    But there are some other side affects, described in the doc:

    Exit the process with status n, without calling cleanup handlers, 
    flushing stdio buffers, etc.
    

    If you do not care about this, you can use it.

    0 讨论(0)
提交回复
热议问题