Apparently I can't get the process resources usage in Mac OS X with psutil after the process got reaped, i.e. after p.wait()
where p
is a psutil.Popen()
instance. So for example, if I try ps.cpu_times().system
where ps
is a psutil.Process()
instance, I get a raise of no such process. What are the other options for measuring the resources usage in a mac (elapsed time, memory and cpu usage)?
Asked
Active
Viewed 741 times
0

C. Porto
- 631
- 3
- 12
- 26
-
related: [measure elapsed time, amount of memory and cpu used by the extern program](http://stackoverflow.com/q/26475636/4279). – jfs Oct 21 '14 at 03:11
-
related: [How to get the max memory usage of a program using psutil in Python](http://stackoverflow.com/q/22732932/4279) – jfs Oct 21 '14 at 03:15
-
describe how each option from [@abarnert's answer](http://stackoverflow.com/a/26476066/4279) has failed in your case e.g., `r = resource.getrusage(resource.RUSAGE_CHILDREN)` – jfs Oct 21 '14 at 03:18
-
Apparently it fits my problem, since I need to invoke just one subprocess, but I'm not quite sure as to how use it and when should I call, is it after the subprocess dies? – C. Porto Oct 21 '14 at 10:28
-
See [Accessing stdout when using “time” in python subproces](http://stackoverflow.com/q/26412634/4279) for the usage example. – jfs Oct 21 '14 at 11:03
1 Answers
0
If the process "dies" or gets reaped how are you supposed to interact with it? Of course you can't, 'cause it's gone. If on the other hand the process is a zombie, then in that case you might be able to extract some info off of it, like the parent PID, but not CPU or memory stats.

Giampaolo Rodolà
- 12,488
- 6
- 68
- 60
-
as it is shown in the comments above, you can get the info even if the process is reaped if you are its parent: [`resource.getrusage(resource.RUSAGE_CHILDREN)`](http://stackoverflow.com/a/26413205/4279) – jfs Oct 29 '14 at 15:38