@@ -33,11 +33,12 @@ async def _stream_subprocess(args: str, **kwargs: Any) -> CompletedProcess:
3333 platform_settings ["env" ] = os .environ
3434
3535 # this part keeps behavior backwards compatible with subprocess.run
36+ tee = kwargs .get ("tee" , True )
3637 stdout = kwargs .get ("stdout" , sys .stdout )
37- if stdout == subprocess .DEVNULL :
38+ if stdout == subprocess .DEVNULL or not tee :
3839 stdout = open (os .devnull , "w" )
3940 stderr = kwargs .get ("stderr" , sys .stderr )
40- if stderr == subprocess .DEVNULL :
41+ if stderr == subprocess .DEVNULL or not tee :
4142 stderr = open (os .devnull , "w" )
4243
4344 # We need to tell subprocess which shell to use when running shell-like
@@ -65,7 +66,7 @@ async def _stream_subprocess(args: str, **kwargs: Any) -> CompletedProcess:
6566 out : List [str ] = []
6667 err : List [str ] = []
6768
68- def tee (line : bytes , sink : List [str ], pipe : Optional [Any ]) -> None :
69+ def tee_func (line : bytes , sink : List [str ], pipe : Optional [Any ]) -> None :
6970 line_str = line .decode ("utf-8" ).rstrip ()
7071 sink .append (line_str )
7172 if not kwargs .get ("quiet" , False ):
@@ -76,13 +77,13 @@ def tee(line: bytes, sink: List[str], pipe: Optional[Any]) -> None:
7677 if process .stdout :
7778 tasks .append (
7879 loop .create_task (
79- _read_stream (process .stdout , lambda l : tee (l , out , stdout ))
80+ _read_stream (process .stdout , lambda l : tee_func (l , out , stdout ))
8081 )
8182 )
8283 if process .stderr :
8384 tasks .append (
8485 loop .create_task (
85- _read_stream (process .stderr , lambda l : tee (l , err , stderr ))
86+ _read_stream (process .stderr , lambda l : tee_func (l , err , stderr ))
8687 )
8788 )
8889
0 commit comments