Message359581
> I am not going to close it as I am unsure if it is by design that
> Windows and Unix python acts differently.
For compatibility, a script should support the spawn start method. Spawning child processes is the only available start method in Windows, and, as of Python 3.8 (see issue 33725), it's the default start method in macOS. This entails passing picklable objects as arguments or with a multiprocessing.Queue or multiprocessing.Pipe -- instead of relying on global values that get inherited via fork.
With a pool you can set up globals with an initializer function. Here's an example of the latter that manually selects the spawn start method:
import multiprocessing as mp
def pool_init(x_value, y_value):
global x, y
x = x_value
y = y_value
if __name__ == '__main__':
mp.set_start_method('spawn')
pool = mp.Pool(processes=2, initializer=pool_init,
initargs=(mp.Value('i', 0), mp.Value('i', 0))) |
|
Date |
User |
Action |
Args |
2020-01-08 11:38:59 | eryksun | set | recipients:
+ eryksun, paul.moore, tim.golden, steven.daprano, zach.ware, steve.dower, Kallah |
2020-01-08 11:38:59 | eryksun | set | messageid: <1578483539.2.0.340837255663.issue39255@roundup.psfhosted.org> |
2020-01-08 11:38:59 | eryksun | link | issue39255 messages |
2020-01-08 11:38:58 | eryksun | create | |
|