From 5dcdfb113831b5c9724453d663720bb6df6f1678 Mon Sep 17 00:00:00 2001 From: Xavier Morel Date: Fri, 9 Aug 2024 10:05:42 +0200 Subject: [PATCH] [IMP] testing: avoid error on test failure / abort It's not entirely clear but I assume if / when a test fails or is aborted (via C-c) pytest kills the stdout somehow. Either way this causes a bunch of `OSError` to be logged out as we try to write to closed pipes. If that occurs, assume the test is gone and just bail out of the thread. --- conftest.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/conftest.py b/conftest.py index 1357fdf3..83d24896 100644 --- a/conftest.py +++ b/conftest.py @@ -1,6 +1,7 @@ from __future__ import annotations import datetime +import errno import select import shutil import threading @@ -515,7 +516,12 @@ def server(request, db, port, module, addons_path, tmpdir): r = os.read(inpt, 4096) if not r: break - os.write(output, r) + try: + os.write(output, r) + except OSError as e: + if e.errno == errno.EBADF: + break + raise buf.extend(r) os.close(inpt)