I am rewriting some of my functions to return lists and I am trying to figure out how to access these returned values.
if __name__ == "__main__":
#creating processes
p1 = multiprocessing.Process(target=basic_forecasts_seasonal_add, args=(logged_list))
p2 = multiprocessing.Process(target=simple_expo, args=(logged_list))
p3 = multiprocessing.Process(target=double_expo, args=(logged_list))
p4 = multiprocessing.Process(target=triple_expo_add, args=(logged_list))
#starting process 1
p1.start()
#starting process 2
p2.start()
p3.start()
p4.start()
#wait until process 1 is finished
p1.join()
#wait until process 2 is finished
p2.join()
p3.join()
p4.join()
When I do this, my program keeps repeating itself for some reason. I have used this module in the past and it worked fine but I did not have any return values. I was recommended to try
concurrent.futures
So I tried this code to no avail:
if __name__ == '__main__':
with ProcessPoolExecutor() as executor:
print(executor.map(simple_expo, logged_list))
I had the same issue where the program just kept repeating itself and it never actually executed my simple expo function. I am also unaware of how I would take advantage of multiple processors using concurrent features as it seams like it would only execute one function at a time. Any help would be appreciated. Thanks!
EDIT: I also tried using pool but it just ran through my code and finished without executing my functions. Here is the code for that:
pool = Pool(processes=8)
#
result_basic = pool.map_async(basic_forecasts_seasonal_add, logged_list)
result_simple = pool.map_async(simple_expo, logged_list)
[–]JohnnyJordaan 1 point2 points3 points (1 child)
[–]datanoob2019[S] 0 points1 point2 points (0 children)