Commit 88ee83bc authored by Deathcrow's avatar Deathcrow

threading for better synchronisation

parent eb74803f
......@@ -11,6 +11,7 @@ import re
import signal
import subprocess
import tempfile
import threading
import time
def parse_senders( sender_args, sender ):
......@@ -116,6 +117,13 @@ def clean_up():
# i['utility_file'].close()
time.sleep(1)
def start_utility(single_sender, scheduled_time):
time.sleep(abs(scheduled_time - time.perf_counter()))
single_sender['utility'] = subprocess.Popen(single_sender['utility_command'],
stdout=single_sender['utility_file'])
signal.signal(signal.SIGINT, signal_handler)
signal.signal(signal.SIGTERM, signal_handler)
......@@ -223,7 +231,17 @@ for key, i in enumerate(sender):
start_time = time.perf_counter()
for key, i in enumerate(sender):
i['utility'] = subprocess.Popen(i['utility_command'], stdout=i['utility_file'])
# i['utility'] = subprocess.Popen(i['utility_command'], stdout=i['utility_file'])
# try to run all senders at the same time through threading 5 seconds from now
scheduled_time = time.perf_counter() + 5
# StartUtilityThread(i, scheduled_time).start()
i['thread'] = threading.Thread(target=start_utility, args=(i, scheduled_time))
i['thread'].start()
#time.sleep(5)
for key, i in enumerate(sender):
i['thread'].join()
print(i['utility'].args)
if args.utility != "netperf":
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment