diff --git a/campaign1.py b/campaign1.py index 5fbc9571d705f2bcbd070b9309841f89da42019a..73e267e9ba743580bbb05513bafb8c4d77f333e0 100644 --- a/campaign1.py +++ b/campaign1.py @@ -1,20 +1,39 @@ -from random import * +import random from time import * -import multiprocessing +import concurrent.futures from instance1 import start_instance # Prepare the start date samples -begin_trace = 1356994806 # according to original SWF header -jun1_unix_time, nov30_unix_time = mktime(strptime('Sun Jun 1 00:00:00 2014')), mktime(strptime('Sun Nov 30 23:59:59 2014')) -jun1, nov30 = (int) (jun1_unix_time - begin_trace), (int) (nov30_unix_time - begin_trace) +begin_trace = 1356994806 # according to original SWF header +jun1_unix_time, nov30_unix_time = mktime(strptime( + 'Sun Jun 1 00:00:00 2014')), mktime(strptime('Sun Nov 30 23:59:59 2014')) +jun1, nov30 = (int)(jun1_unix_time - + begin_trace), (int)(nov30_unix_time - begin_trace) random.seed(1997) -instances = [] -for i in range(2): - start_date = randint(jun1, nov30 - 72 * 3600) - instane = multiprocessing.Process(target=start_instance, args=) +nb_expe = 2 + + +def print_two(a, b): + print(a, b) + sleep(3) + print("hello") + return 0 + + +start_dates = [random.randint(jun1, nov30 - 72 * 3600) + for _ in range(nb_expe)] + +with concurrent.futures.ProcessPoolExecutor() as executor: + + instances = [executor.submit(start_instance, i, start_dates[i]) + for i in range(nb_expe)] + + for instance in concurrent.futures.as_completed(instances): + print(instance.result()) + # For every start date -# Call the one_instance file with this date \ No newline at end of file +# Call the one_instance file with this date diff --git a/instance1.py b/instance1.py index cc3fb943a08f3c3593eca2da799f381036be6629..0b0a4bc221de2728aecf8d528d05526f8c5b8b14 100755 --- a/instance1.py +++ b/instance1.py @@ -99,7 +99,7 @@ def start_instance(expe_num, start_date): ###### Output data treatment ###### # Produce the utilisation viz? - + return 0 def main(): parser = argparse.ArgumentParser(