From db415e58b3bde6786bd565588285924c1f751d89 Mon Sep 17 00:00:00 2001 From: Sergey Shepelev Date: Wed, 10 Aug 2016 11:20:33 +0500 Subject: [PATCH] tests: configurable timeout for run_python/isolated --- tests/__init__.py | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/tests/__init__.py b/tests/__init__.py index 62bae83..b9e0add 100644 --- a/tests/__init__.py +++ b/tests/__init__.py @@ -302,7 +302,7 @@ def get_database_auth(): return retval -def run_python(path, env=None, args=None): +def run_python(path, env=None, args=None, timeout=None): new_argv = [sys.executable] new_env = os.environ.copy() if path: @@ -323,17 +323,19 @@ def run_python(path, env=None, args=None): stdin=subprocess.PIPE, stdout=subprocess.PIPE, ) + if timeout is None: + timeout = 10 try: - output, _ = p.communicate(timeout=30) + output, _ = p.communicate(timeout=timeout) except subprocess.TimeoutExpired: p.kill() - output, _ = p.communicate(timeout=30) + output, _ = p.communicate(timeout=timeout) return "{0}\nFAIL - timed out".format(output) return output -def run_isolated(path, prefix='tests/isolated/', env=None, args=None): - output = run_python(prefix + path, env=env, args=args).rstrip() +def run_isolated(path, prefix='tests/isolated/', env=None, args=None, timeout=None): + output = run_python(prefix + path, env=env, args=args, timeout=timeout).rstrip() if output.startswith(b'skip'): parts = output.split(b':', 1) skip_args = []