I have a pool of 2 processes. Process #1 with infinite loop. I need to stop infinite loop in process #1 when something happens in process #2. How to pass info from process #1 to process #2?
def do_smth(value):
a = 0
if value == "1":
while 1:
time.sleep(0.5)
print("process_1", a)
if a == 10: break
if value == "2":
while a < 10:
time.sleep(0.5)
print("process_2", a)
a +=1
def make_a_pool(all):
with multiprocessing.Pool(processes=2) as pool:
pool.map(do_smth, all)
if __name__ == "__main__":
all = ["1", "2"]
make_a_pool(all)
allis the name of a built-in, so you should refrain from defining it to be something else.