Skip to content

Commit 17c95e8

Browse files
committed
Attempt to fix flaky integration tests
1 parent 283130f commit 17c95e8

File tree

1 file changed

+11
-0
lines changed

1 file changed

+11
-0
lines changed

tests/gunicorn_utils.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
import concurrent.futures
22
import contextlib
33
import multiprocessing
4+
import time
45
from typing import Iterator
56

67
from gunicorn.app.wsgiapp import WSGIApplication
@@ -83,4 +84,14 @@ def run_gunicorn(config_path: str = "config/gunicorn.conf.py", **kwargs) -> Iter
8384

8485
yield
8586
finally:
87+
# See https://github.com/python-discord/snekbox/issues/177
88+
# Sleeping before terminating the process avoids a case where
89+
# terminating the process can take >30 seconds.
90+
time.sleep(0.2)
91+
8692
proc.terminate()
93+
94+
# Actually wait for the process to finish. There doesn't seem to be a
95+
# reliable way of checking if the timeout was reached or this ended normally,
96+
# but if the timeout is reached it will probably error later anyway.
97+
proc.join(timeout=10)

0 commit comments

Comments
 (0)