[Python-ideas] Adding a subprocess.CompletedProcess class
Wes Turner
wes.turner at gmail.com
Sun Feb 1 17:29:05 CET 2015
On Sun, Feb 1, 2015 at 7:48 AM, Paul Moore <p.f.moore at gmail.com> wrote:
> 29 January 2015 at 21:09, Thomas Kluyver <thomas at kluyver.me.uk> wrote:
> > On 29 January 2015 at 03:47, Nick Coghlan <ncoghlan at gmail.com> wrote:
> >>
> >> I still suspect we should be offering a simpler way to decouple the
> >> creation of the pipes from the subprocess call, but I have no idea
> >> what that API should look like,
> >
> >
> > Presumably that would need some kind of object representing a
> > not-yet-started process.
http://sarge.readthedocs.org/en/latest/reference.html#Pipeline
p = sarge.run('sleep 60', async=True)
assert type(p) == sarge.Pipeline
> Technically, that could be Popen, but for backwards
> > compatibility the Popen constructor needs to start the process, and p =
> > Popen(..., start=False) seems inelegant.
>
> The thing I've ended up needing to do once or twice, which is
> unreasonably hard with subprocess, is to run the command and capture
> the output, but *still* write it to stdout/stderr. So the user gets to
> see the command's progress, but you can introspect the results
> afterwards.
> The hard bit is to do this while still displaying the output as it
> arrives. You basically need to manage the stdout and stderr pipes
> yourself, do nasty multi-stream interleaving, and deal with the
> encoding/universal_newlines stuff on the captured data. In a
> cross-platform way :-(
>
http://sarge.readthedocs.org/en/latest/tutorial.html#buffering-issues
'| tee filename.log'
-------------- next part --------------
An HTML attachment was scrubbed...
URL: <http://mail.python.org/pipermail/python-ideas/attachments/20150201/8d659e9f/attachment.html>
More information about the Python-ideas
mailing list