Python - calling multiprocessing.pool inside a daemon

后端 未结 1 1165
一生所求
一生所求 2021-01-07 02:04

I have a Python script which spawns a daemon process. Inside the process, I am using multiprocessing.pool to run 1 to 4 p

相关标签:
1条回答
  • 2021-01-07 02:09

    Quoting from the documentation of multiprocessing:

    daemon

    The process’s daemon flag, a Boolean value. This must be set before start() is called.

    The initial value is inherited from the creating process.

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

    Note that a daemonic process is not allowed to create child processes. Otherwise a daemonic process would leave its children orphaned if it gets terminated when its parent process exits. Additionally, these are not Unix daemons or services, they are normal processes that will be terminated (and not joined) if non-daemonic processes have exited.

    Since multiprocessing.Pool has to create worker processes, you cannot daemonaize a process using it.

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