Python Forum
capture stdout from child processes
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
capture stdout from child processes
#1
the parent process, which is not running any threads, will be running more than one child processes (using the multiprocessing module) that will be running things (possibly not Python) that output to stdout. i want the parent to capture this output. apparently, i cannot use multiprocessing.Pipe() since that does not capture stdout. it appears that my only option is to create a system level pipe using os.pipe() and pass the file descriptors to the child so it can close the read end and substitute stdout with the write end before it (the child process) does anything else. but i am afraid that is too Unix specific and not portable enough to run on Windows. does anyone know anything about this? is there a way to code this to be portable?

the parent will not be reading child process data in parallel. instead, it will read each child one at a time in a specific order. it will block until the first child begins to do output. the other child processes will block if they do any output until the parent gets around to reading there output.
Tradition is peer pressure from dead people

What do you call someone who speaks three languages? Trilingual. Two languages? Bilingual. One language? American.
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  launch processes from threads Skaperen 9 808 Feb-21-2024, 01:16 AM
Last Post: Skaperen
  printing interleaved lines from many processes Skaperen 2 2,066 Feb-20-2024, 01:48 AM
Last Post: wearsafe
  setting STDOUT and/or STDERR Skaperen 7 989 Dec-08-2023, 08:38 AM
Last Post: Gribouillis
  order to call Popen for 2 piped processes Skaperen 0 1,164 Oct-22-2020, 11:31 PM
Last Post: Skaperen
  combining stdout and stderr Skaperen 1 1,747 Nov-01-2019, 07:06 AM
Last Post: Gribouillis

Forum Jump:

User Panel Messages

Announcements
Announcement #1 8/1/2020
Announcement #2 8/2/2020
Announcement #3 8/6/2020