From 28b6a766c3b13333d4286c1dd548f3c2312aafed Mon Sep 17 00:00:00 2001 From: Tyler Fox Date: Wed, 1 Nov 2023 11:26:30 -0700 Subject: [PATCH] If stdout/stderr are null streams, don't forward data to them. --- preditor/stream/director.py | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/preditor/stream/director.py b/preditor/stream/director.py index ded2338f..87206703 100644 --- a/preditor/stream/director.py +++ b/preditor/stream/director.py @@ -32,9 +32,11 @@ def __init__(self, manager, state, old_stream=None, *args, **kwargs): old_stream = None elif old_stream is None: if state == STDOUT: - old_stream = sys.stdout + if getattr(sys.stdout, 'name', '') != 'nul': + old_stream = sys.stdout elif state == STDERR: - old_stream = sys.stderr + if getattr(sys.stderr, 'name', '') != 'nul': + old_stream = sys.stderr self.old_stream = old_stream def close(self):