Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

multiprocessing write to dict

import multiprocessing
manager = multiprocessing.Manager()
shared_dict = manager.dict()

def worker1(d):
    d["a"] = 1

def worker2(d):
    d["b"] = 2

process1 = multiprocessing.Process(
    target=worker1, args=[shared_dict])
process2 = multiprocessing.Process(
    target=worker2, args=[shared_dict])

process1.start()
process2.start()
process1.join()
process2.join()

print shared_dict
OUTPUT
{'a': 1, 'b': 2}
Source by www.kite.com #
 
PREVIOUS NEXT
Tagged: #multiprocessing #write #dict
ADD COMMENT
Topic
Name
5+1 =