[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.
This commit is contained in:
Xavier Morel 2024-08-09 10:05:42 +02:00
parent d5bda3d3e2
commit 5dcdfb1138

View File

@ -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)