Comment #2 on issue 242 by g.rodola: get a process by name and get a
processes' descendants
http://code.google.com/p/psutil/issues/detail?id=242
> patch in attachment adds a get_lowest_descendants()
> method on the Process object, which fetches all
> descendants from a process, that don't have
> child processes themselves.
Mmm interesting.
I think I don't have a clear mind about this yet.
At first it seems kind of useful, on the other hand I'm not sure about its
reliability.
Imagine this:
process A creates process B which creates process C
In normal circumstances your method would return A, B and C, but if B gets
terminated in meantime you're gonna lose the reference to C and get only A
in return.
Other than that, I think this would be better served by adding an extra
argument to get_children() method:
>>> get_children(recursive=True)
...and make it return only B and C but not itself (A).
Also, it seems natural to make get_children() return an iterator rather
than a list.
The same should be done for get_open_files(), get_connections() and
get_threads() (I'll file a new ticket for that).
Jay, what do you think?
--
You received this message because you were CC'd on the issue.
You may adjust your notification preferences at:
https://code.google.com/hosting/settings
Reply to this email to add a comment.
In your example where process A creates process B which creates process C,
the code would only return process C, not B, since B has children.
Another option for my use case would then be
>>> filter(lambda x: len(x.children)==0,get_children(recursive=True))
Comment #4 on issue 242 by g.rodola: get a process by name and get a
processes' descendants
http://code.google.com/p/psutil/issues/detail?id=242
This is now implemented in r1282.
Please look at the docstring and let me know if with this you're able to
cover your use case.
Change recursion algorithm as r1283.