This is harder than it looks. Popen.communicate buffers the entire output, so we have to build our own non-blocking IO loop.
Solve stdout/stderr synchronization as a bonus!
And timestamps!
This is harder than it looks. Popen.communicate buffers the entire output, so we have to build our own non-blocking IO loop.
Solve stdout/stderr synchronization as a bonus!
And timestamps!
Subject | Repo | Branch | Lines +/- | |
---|---|---|---|---|
Stream subprocess stdout and stderr to log file | wikimedia/fundraising/process-control | master | +111 -57 |
Change 345424 had a related patch set uploaded (by Ejegg):
[wikimedia/fundraising/process-control@master] Stream subprocess stdout and stderr to log file
Change 345424 merged by jenkins-bot:
[wikimedia/fundraising/process-control@master] Stream subprocess stdout and stderr to log file
@cwdent found some libraries that might simplify our code:
https://docs.python.org/3/library/asyncio.html
https://pypi.python.org/pypi/trollius/