Status of mixing multiprocessing and threading in Python

前端 未结 1 1500
一向
一向 2020-12-02 18:50

What are best practices or work-arounds for using both multiprocessing and user threads in the same python application in Linux with respect to Issue 6721, Locks in python s

相关标签:
1条回答
  • 2020-12-02 19:20

    You will be safe if you fork off additional processes while you still have only one thread in your program (that is, fork from main thread, before spawning worker threads).

    Your use case looks like you don't even need multiprocessing module; you can use subprocess (or even simpler os.system-like calls).

    See also Is it safe to fork from within a thread?

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