[Tutor] working intime on pipes

Jan Kenin jankenin at gmx.de
Thu Apr 13 06:47:08 EDT 2023


Hello,

I have command, that runs pretty long and outputs many lines, that I
would like to filter. I call the command with

p=subprocess.Popen( command, stdout=out )

p.wait()

If out were sys.stdout, all output would be printed to the screen, which
I dont want to.

If out were an object with a write( *args ) attribute, this is not
called by p. p just calls out.fileno() and all is written to out without
using the write attribute.

How can I work on the lines sent to out, _before_ p has finished?

Thanks for usefull advice!



More information about the Tutor mailing list