diff options
Diffstat (limited to 'testsuite/driver/testlib.py')
-rw-r--r-- | testsuite/driver/testlib.py | 20 |
1 files changed, 19 insertions, 1 deletions
diff --git a/testsuite/driver/testlib.py b/testsuite/driver/testlib.py index db40d6f82f..50f5133386 100644 --- a/testsuite/driver/testlib.py +++ b/testsuite/driver/testlib.py @@ -37,6 +37,11 @@ if config.use_threads: import threading pool_sema = threading.BoundedSemaphore(value=config.threads) +def acquire_all() -> None: + global pool_sema + for i in range(config.threads): + pool_sema.acquire() + global wantToStop wantToStop = False @@ -2340,6 +2345,19 @@ def dump_file(f: Path): except Exception: print('') +# Wait for a process but kill it if a global trigger is sent +def process_loop(r): + finished = False + while not (stopping() or finished): + try: + r.wait(timeout=1) + finished = True + except subprocess.TimeoutExpired: + pass + if not finished: + r.terminate() + return r.communicate() + def runCmd(cmd: str, stdin: Union[None, Path]=None, stdout: Union[None, Path]=None, @@ -2372,8 +2390,8 @@ def runCmd(cmd: str, stdout=subprocess.PIPE, stderr=hStdErr, env=ghc_env) + stdout_buffer, stderr_buffer = process_loop(r) - stdout_buffer, stderr_buffer = r.communicate() finally: if stdin_file: stdin_file.close() |