Re: Issue 242 in psutil: get a process by name and get a processes' descendants

49 views
Skip to first unread message

psu...@googlecode.com

unread,
Jan 19, 2012, 8:34:23 AM1/19/12
to psu...@googlegroups.com
Updates:
Status: WaitingForReview
Cc: psu...@googlegroups.com

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.

psu...@googlecode.com

unread,
Jan 19, 2012, 9:07:37 AM1/19/12
to psu...@googlegroups.com

Comment #3 on issue 242 by dolfandr...@gmail.com: get a process by name and

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))

psu...@googlecode.com

unread,
Apr 7, 2012, 11:38:30 AM4/7/12
to psu...@googlegroups.com
Updates:
Status: Started

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.

psu...@googlecode.com

unread,
Apr 8, 2012, 8:38:09 AM4/8/12
to psu...@googlegroups.com

Comment #5 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

Change recursion algorithm as r1283.

Reply all
Reply to author
Forward
0 new messages