Python Multiprocess Diff Between Windows And Linux
I have a script called jobrunner.py that calls class methods in main.py. See below... # jobrunner.py from multiprocessing import Process import main from main import BBOX def _a(a
Solution 1:
You shouldn't expect the values of global variables that you set in the parent process to be automatically propagated to the child processes.
Your code happens to work on Unix-like platforms because on those platforms multiprocessing
uses fork()
. This means that every child processes gets a copy of the parent process's address space, including all global variables.
This isn't the case on Windows; every variable from the parent process that needs to be accessed by the child has to be explicitly passed down or placed in shared memory.
Once you do this, your code will work on both Unix and Windows.
Post a Comment for "Python Multiprocess Diff Between Windows And Linux"