diff options
author | 2023-06-22 12:49:29 +0000 | |
---|---|---|
committer | 2023-06-22 12:53:08 +0000 | |
commit | 17c95e8a2e4a2788e43fb38d0ec116201db69524 (patch) | |
tree | 75e3edb7816902116703ab2ab3854d42db5cb633 | |
parent | Fix issue when running individual integration tests (diff) |
Attempt to fix flaky integration tests
-rw-r--r-- | tests/gunicorn_utils.py | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/tests/gunicorn_utils.py b/tests/gunicorn_utils.py index 15a2b58..54a51df 100644 --- a/tests/gunicorn_utils.py +++ b/tests/gunicorn_utils.py @@ -1,6 +1,7 @@ import concurrent.futures import contextlib import multiprocessing +import time from typing import Iterator from gunicorn.app.wsgiapp import WSGIApplication @@ -83,4 +84,14 @@ def run_gunicorn(config_path: str = "config/gunicorn.conf.py", **kwargs) -> Iter yield finally: + # See https://github.com/python-discord/snekbox/issues/177 + # Sleeping before terminating the process avoids a case where + # terminating the process can take >30 seconds. + time.sleep(0.2) + proc.terminate() + + # Actually wait for the process to finish. There doesn't seem to be a + # reliable way of checking if the timeout was reached or this ended normally, + # but if the timeout is reached it will probably error later anyway. + proc.join(timeout=10) |