This might be an obvious thing, but I can't seem to figure out how to do it.
Assuming that I spawn a process like this:
popen = subprocess.Popen(args, executable=executable,
bufsize=-1,
stdin=subprocess.PIPE,
stdout=subprocess.PIPE,
close_fds=True,
env={})
popen.wait()
Is there any way I can measure the cpu usage of this child, but not the grandchildren?
resource.getrusage(resource.RUSAGE_CHILDREN)
Gives me all children and granchildren.
You can use psutil