|
|
|
|
|
by hot_gril
776 days ago
|
|
I tried this on a Linux machine in Py3 earlier, which I think is equivalent to your example: from multiprocessing import Pool
shared = {}
def f(x):
global shared # idk if this matters but tried without it too
shared[x] = x
print(shared)
if __name__ == '__main__':
with Pool(5) as p:
p.map(f, [1, 2, 3])
print(shared)
It printed {1: 1}, {2: 2}, {3: 3} then {} at the end. So the parent and other children didn't see the change made by each child. Doesn't seem like they're RW sharing. |
|