Python Forum
Get stdout of a running process - Printable Version

+- Python Forum (https://python-forum.io)
+-- Forum: Python Coding (https://python-forum.io/forum-7.html)
+--- Forum: General Coding Help (https://python-forum.io/forum-8.html)
+--- Thread: Get stdout of a running process (/thread-29148.html)



Get stdout of a running process - yok0 - Aug-20-2020

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


This forum uses Lukasz Tkacz MyBB addons.
Forum use Krzysztof "Supryk" Supryczynski addons.