From e51cdd7a5fe215c948eca0ef1bc6aaa49dc304dc Mon Sep 17 00:00:00 2001 From: RohanImmanuel Date: Thu, 29 Sep 2022 03:03:43 +0530 Subject: [PATCH] max parallels added --- pavement.py | 12 ++++++++++-- 1 file changed, 10 insertions(+), 2 deletions(-) diff --git a/pavement.py b/pavement.py index 3accb7c..8d3c4f4 100644 --- a/pavement.py +++ b/pavement.py @@ -1,9 +1,12 @@ from paver.easy import * from paver.setuputils import setup from multiprocess import Process +from multiprocessing import Semaphore import platform import json +MAX_PARALLELS = 2 + setup( name = "pytest-browserstack", version = "0.1.0", @@ -16,11 +19,12 @@ packages=['tests'] ) -def run_py_test(config, task_id=0): +def run_py_test(config, task_id=0, sema=0): if platform.system() == "Windows": sh('cmd /C "set CONFIG_FILE=config/%s.json && set TASK_ID=%s && pytest -s tests/test_%s.py --driver Browserstack"' % (config, task_id, config)) else: sh('CONFIG_FILE=config/%s.json TASK_ID=%s pytest -s tests/test_%s.py --driver Browserstack' % (config, task_id, config)) + sema.release() @task @consume_nargs(1) @@ -31,7 +35,11 @@ def run(args): with open(config_file) as data_file: CONFIG = json.load(data_file) environments = CONFIG['environments'] + sema = Semaphore(MAX_PARALLELS) for i in range(len(environments)): - p = Process(target=run_py_test, args=(args[0], i)) + sema.acquire() + p = Process(target=run_py_test, args=(args[0], i, sema)) jobs.append(p) p.start() + for p in jobs: + p.join()