Answers for "shared list in multiprocessing python"

0

shared list in multiprocessing python

import multiprocessing
manager = multiprocessing.Manager()
shared_list = manager.list()

def worker1(l):
    l.append(1)

def worker2(l):
    l.append(2)

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

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

print shared_listOutput[1, 2]
Posted by: Guest on July-30-2021

Code answers related to "shared list in multiprocessing python"

Python Answers by Framework

Browse Popular Code Answers by Language