Horst Koiner wrote at 2023-5-9 11:13 -0700:
> ...
>For production i run the program with stdout=subprocess.PIPE and i can fetch 
>than the output later. For just testing if the program works, i run with 
>stdout=subprocess.STDOUT and I see all program output on the console, but my 
>program afterwards crashes since there is nothing captured in the python 
>variable. So I think I need to have the functionality of subprocess.PIPE and 
>subprcess.STDOUT sametime.

You might want to implement the functionality of the *nix programm
`tee` in Python.
`tee` reads from one file and writes the data to several files,
i.e. it multiplexes one input file to several output files.

Pyhton's `tee` would likely be implemented by a separate thread.

For your case, the input file could be the subprocess's pipe
and the output files `sys.stdout` and a pipe created by your own
used by your application in place of the subprocess's pipe.
-- 
https://mail.python.org/mailman/listinfo/python-list

Reply via email to