I followed this youtube video by Corey Schafer to use the multiprocessing.
def test3(x):
y=0;
for ix in range (0,x):
y=y+ix*2
print(y,flush=True) #still didn't work
time.sleep(1);
return y;
However, the code does not print the result nor return the value.
import multiprocessing
cores = multiprocessing.cpu_count()
print(cores)
start =time.time()
p1=multiprocessing.Process(target=test3,args=(100000000,))
p2=multiprocessing.Process(target=test3,args=[100000000]) #the variations
p1.start()
p2.start()
p1.join()
p2.join()
finish =time.time()
print(f"Finished in {round(finish-start,2)} seconds()")
In the python multiprocessing it's not printing nor sleeping, and I tried several methods such as add more sleep() and use the flush() in the print but none of those were working.
Why the Processing was not working and how to fix it? and get a return value?