Answer the question
In order to leave comments, you need to log in
Why is variable change not visible from Python process?
Hello!
I posted a simple example code:
import os
import time
from multiprocessing import Pool, Process
my_list = []
def do(x):
my_list.append(x)
time.sleep(.5)
return x
def write_info():
while True:
os.system('clear')
print('My list count:', len(my_list))
time.sleep(1)
if __name__ == '__main__':
p_info = Process(target=write_info)
p_info.start()
with Pool(5) as p:
result = p.map(do, range(100))
p_info.join()
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question