From 17c95e8a2e4a2788e43fb38d0ec116201db69524 Mon Sep 17 00:00:00 2001 From: wookie184 Date: Thu, 22 Jun 2023 12:49:29 +0000 Subject: Attempt to fix flaky integration tests --- tests/gunicorn_utils.py | 11 +++++++++++ 1 file changed, 11 insertions(+) (limited to 'tests') 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) -- cgit v1.2.3