Skip to content
GitLab
Menu
Projects
Groups
Snippets
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in
Toggle navigation
Menu
Open sidebar
Evan Edmond
fslpy
Commits
5614ce16
Commit
5614ce16
authored
May 27, 2018
by
Paul McCarthy
🚵
Browse files
RF: Improve test for bytes-vs-str output streams
parent
58b22bfb
Changes
1
Hide whitespace changes
Inline
Side-by-side
fsl/utils/run.py
View file @
5614ce16
...
...
@@ -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
omode
s
[
i
]
:
o
.
write
(
line
)
else
:
o
.
write
(
line
.
decode
(
'utf-8'
))
t
=
threading
.
Thread
(
target
=
realForward
)
t
.
daemon
=
True
...
...
Write
Preview
Supports
Markdown
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment