From 3befa7a979a0093d3678ea926fe7d5b83a780353 Mon Sep 17 00:00:00 2001 From: Johanna England Date: Fri, 29 Jul 2022 09:44:48 +0200 Subject: [PATCH] Stop resource leakage when reading gunicorn file --- tests/functional/conftest.py | 11 ++++++----- 1 file changed, 6 insertions(+), 5 deletions(-) diff --git a/tests/functional/conftest.py b/tests/functional/conftest.py index f974f3316c..f0ea3afe7e 100644 --- a/tests/functional/conftest.py +++ b/tests/functional/conftest.py @@ -37,11 +37,12 @@ def pytest_unconfigure(config): def start_gunicorn(): global gunicorn gunicorn_log = open("reports/gunicorn.log", "ab") - gunicorn = subprocess.Popen( - ['gunicorn', 'navtest_wsgi:application'], - stdout=gunicorn_log, - stderr=subprocess.STDOUT, - ) + with gunicorn_log: + gunicorn = subprocess.Popen( + ['gunicorn', 'navtest_wsgi:application'], + stdout=gunicorn_log, + stderr=subprocess.STDOUT, + ) def stop_gunicorn():