Skip to content
Snippets Groups Projects
Commit 5614ce16 authored by Paul McCarthy's avatar Paul McCarthy :mountain_bicyclist:
Browse files

RF: Improve test for bytes-vs-str output streams

parent 58b22bfb
No related branches found
No related tags found
No related merge requests found
......@@ -127,11 +127,16 @@ def run(*args, **kwargs):
# the process stdout/err on separate threads
# to avoid deadlocks.
def forward(in_, *outs):
# not all file-likes have a mode attribute -
# if not present, assume a string stream
omodes = [getattr(o, 'mode', 'w') for o in outs]
def realForward():
for line in in_:
for o in outs:
if 'b' in o.mode: o.write(line)
else: o.write(line.decode('utf-8'))
for i, o in enumerate(outs):
if 'b' in omodes[i]: o.write(line)
else: o.write(line.decode('utf-8'))
t = threading.Thread(target=realForward)
t.daemon = True
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment