From cf977331e36c42b892c77ee4a4ec57087e45ebdb Mon Sep 17 00:00:00 2001 From: Thefeli73 Date: Wed, 7 Oct 2020 03:34:42 +0200 Subject: [PATCH] PARALLELISERAD LAUNCHER!!! --- launcher.py | 29 ++++++++++++++++++++++------- 1 file changed, 22 insertions(+), 7 deletions(-) diff --git a/launcher.py b/launcher.py index 806528a..3dde4cb 100644 --- a/launcher.py +++ b/launcher.py @@ -1,8 +1,23 @@ import main -number_of_launches = 4 -result_list = [] -for i in range(number_of_launches): - result_list.append(main.main()) -for result in result_list: - print("Game " + result[0] + " had a score of: " + str(result[1])) -input("Press Enter to exit") \ No newline at end of file +import time +from multiprocessing import Pool +import multiprocessing + +proc_running = 4 # MAX 4!!! + + +def run_main(n): + result = main.main() + return result + + +def launch(list): + for result in list: + print("Game " + result[0] + " had a score of: " + str(result[1])) + input("Press Enter to exit") + + +if __name__ == '__main__': + with Pool(proc_running) as p: + results = p.map(run_main, range(proc_running)) + launch(results)