Skip to content

Commit

Permalink
Avoid attempt to write to wrong pipe (#44)
Browse files Browse the repository at this point in the history
Do not attempt to write to pipe object unless it has a write
attribute. This should avoid a runtime error like:

AttributeError: 'int' object has no attribute 'write'

Observed while testing use inside ansible-compat.
  • Loading branch information
ssbarnea authored Sep 6, 2021
1 parent a8cec8e commit 7e5b824
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion src/subprocess_tee/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -74,7 +74,7 @@ async def _stream_subprocess(args: str, **kwargs: Any) -> CompletedProcess:
def tee_func(line: bytes, sink: List[str], pipe: Optional[Any]) -> None:
line_str = line.decode("utf-8").rstrip()
sink.append(line_str)
if not kwargs.get("quiet", False):
if not kwargs.get("quiet", False) and hasattr(pipe, "write"):
print(line_str, file=pipe)

loop = asyncio.get_event_loop()
Expand Down

0 comments on commit 7e5b824

Please sign in to comment.