[issue21504] can the subprocess module war using os.wait4 and so return usage?
report at bugs.python.org
Thu May 15 03:09:19 CEST 2014
donald petravick added the comment:
Victor, thanks so much for reading my ticket and contacting me.
I prototyped what makes sense to me by subclassing subprocess.Popen and
Over-ridden the wait method to do what I suggested. Proof of concept
It¹s a bit of a hack since I cribbed code from Popen.wait().
Now that you¹ve made me think harder, The use case that stood out was the
where I called the communicate() method which both handles IO and the
of the process AFAICT.
I _do_ understand the portability argument you are making (and am clueless
what¹s to be done with windows).
On 5/14/14, 5:28 PM, "STINNER Victor" <report at bugs.python.org> wrote:
>STINNER Victor added the comment:
>I guess that you mean "Popen" when you write "Pipe"?
>Even if Popen has a high-level wait() method implemented with
>os.waitpid(), you are free to use a low-level function using the pid
>proc = subprocess.Popen(...)
>> have an new data member, rusage, make the resource usage available to
>I don't know how to get the rusage of a specific child process, but you
>can use resource.getrusage(resource.RUSAGE_CHILDREN) which gives the
>usage of *all* child processes. Again, you have the pid, and so you are
>free to use any function to retrieve the resource usage of the child
>process. See also this project which can help you:
>I don't think that the subprocess should be modified to your use case,
>it's already possible to implement you use cases without modify it.
>Python is a (very) portable language, and it's very hard to provide the
>same API for such low-level metrics (rusage). I don't think that Windows
>provides exactly the same data for example.
>You can build your own module on top of subprocess and other modules like
>Python tracker <report at bugs.python.org>
Added file: http://bugs.python.org/file35256/subprocess4.pyc
Python tracker <report at bugs.python.org>
-------------- next part --------------
A non-text attachment was scrubbed...
Size: 1402 bytes
Desc: not available
More information about the Python-bugs-list