Python Forum
Get stdout of a running process
Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
Get stdout of a running process
#1
Hi,

I'm working on a program that launch multiple subprocess in background.
Those processes return data continuously so I piped stdout to a file, to retrieve it later while running, with a command like myApp --show processName

subprocess.Popen(cmd, stdout=logfile, stderr=logfile, text=True)
It works fine, I loop over the file by reading lines but it's slow and I lose the colored formated text (warnings and errors) threw by the command. It's faster when reading /proc/pid/fd/1 but still slow.

So I'm wondering if there's any way to get the stdout of a running process with it's pid?

Thanks
Reply


Possibly Related Threads…
Thread Author Replies Views Last Post
  [subprocess] Why stdout sent to stderr? Winfried 3 421 Jan-26-2024, 07:26 PM
Last Post: snippsat
  Performance options for sys.stdout.writelines dgrunwal 11 2,997 Aug-23-2022, 10:32 PM
Last Post: Pedroski55
  Controlling what get outputted to stdout when running external commands Daring_T 4 2,111 Jan-30-2022, 05:40 PM
Last Post: bowlofred
  changing stdout and stderr Skaperen 4 2,645 Dec-02-2020, 08:58 PM
Last Post: Skaperen
  will with sys.stdout as f: close sys.stdout? Skaperen 9 4,499 Nov-03-2019, 07:57 AM
Last Post: Gribouillis
  How to sharing object between multiple process from main process using Pipe Subrata 1 3,619 Sep-03-2019, 09:49 PM
Last Post: woooee
  Add stdout to text file maxtimbo 3 3,099 Feb-05-2019, 12:53 AM
Last Post: maxtimbo
  Multiprocessing Module Running An Infinite Child Process Even After Completion hsikora 0 3,836 Dec-19-2018, 08:01 AM
Last Post: hsikora
  Pausing a running process? MuntyScruntfundle 2 7,141 Nov-14-2018, 05:14 PM
Last Post: woooee
  running just one process shared among uses Skaperen 3 2,928 Aug-07-2018, 12:12 AM
Last Post: Skaperen

Forum Jump:

User Panel Messages

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