Commit baad53c4 authored by Deathcrow's avatar Deathcrow
Browse files

workaround for pickling bug (?)

parent 619a3927
...@@ -8,6 +8,7 @@ import argparse ...@@ -8,6 +8,7 @@ import argparse
import copy import copy
import multiprocessing import multiprocessing
import os import os
import pickle
import re import re
import random import random
import signal import signal
...@@ -154,18 +155,21 @@ def clean_up(): ...@@ -154,18 +155,21 @@ def clean_up():
if args.cpunetlog != "": if args.cpunetlog != "":
cpunetlog.terminate() cpunetlog.terminate()
for i in sender: for i in sender:
subprocess.Popen(["kill", "-9", i['utility_data'][0]])
# if i['utility'].returncode == None: # if i['utility'].returncode == None:
try: # try:
i['utility'].kill() # i['utility'].kill()
except ProcessLookupError: # except ProcessLookupError:
pass # pass
# i['utility_file'].close() # i['utility_file'].close()
time.sleep(1) time.sleep(1)
def start_utility(sender_key, scheduled_time): def start_utility(sender_key, scheduled_time):
time.sleep(abs(scheduled_time - time.perf_counter())) time.sleep(abs(scheduled_time - time.perf_counter()))
return subprocess.Popen(sender[sender_key]['utility_command'], process = subprocess.Popen(sender[sender_key]['utility_command'],
stdout=sender[sender_key]['utility_file']) stdout=sender[sender_key]['utility_file'])
data = [process.pid, process.args]
return data
...@@ -318,8 +322,8 @@ with multiprocessing.Pool(len(sender)) as pool: ...@@ -318,8 +322,8 @@ with multiprocessing.Pool(len(sender)) as pool:
#time.sleep(5) #time.sleep(5)
for key, i in enumerate(sender): for key, i in enumerate(sender):
# i['thread'].join() # i['thread'].join()
i['utility'] = pool_results[key].get() i['utility_data'] = pool_results[key].get()
print(i['utility'].args) print(i['utility_data'][1])
...@@ -332,7 +336,7 @@ if args.utility != "netperf": ...@@ -332,7 +336,7 @@ if args.utility != "netperf":
line = ss_file.readline() line = ss_file.readline()
while line is not "": while line is not "":
for key, i in enumerate(sender): for key, i in enumerate(sender):
if re.search(str(i['utility'].pid), line): if re.search(str(i['utility_data'][0]), line):
start = re.search(i['src'], line).end()+1 start = re.search(i['src'], line).end()+1
print(line[start:start+5]) print(line[start:start+5])
i['src_port'] = line[start:start+5] i['src_port'] = line[start:start+5]
......
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