diff --git a/commands.py b/commands.py index 11e47e3..ddb09ac 100644 --- a/commands.py +++ b/commands.py @@ -24,7 +24,7 @@ def run_check(clargs): get_data = DataGetter(clargs.timeout, clargs.quiet) run = serial if clargs.serial else parallel - data = run(get_data, pvs, chans) + data = run(get_data, pvs, names=chans) df = pd.DataFrame(data).T df = df.infer_objects() #TODO: why is this needed? diff --git a/utils/execute.py b/utils/execute.py index 722fbc6..cc72f4d 100644 --- a/utils/execute.py +++ b/utils/execute.py @@ -1,20 +1,21 @@ from concurrent.futures import ThreadPoolExecutor -def parallel(func, targets, names=None): +def parallel(func, *targets, names=None): with ThreadPoolExecutor() as executor: - results = executor.map(func, targets) - if names: + results = executor.map(func, *targets) + if names is not None: return dict(zip(names, results)) else: return list(results) -def serial(func, targets, names=None): - if names: - return {n: func(t) for n, t in zip(names, targets)} +def serial(func, *targets, names=None): + targets = zip(*targets) + if names is not None: + return {n: func(*t) for n, t in zip(names, targets)} else: - return [func(t) for t in targets] + return [func(*t) for t in targets]