Monday, May 20, 2013
Recursive Function for walking down a list and getting children of children
def GetChildren(self,lvl=0): global ListOfChildren
global Memcount
if lvl == 0: ListOfChildren = []
Memcount = self.GetHighestRSS()
for child in self.ListOfChildProcesses:
child.lvl = lvl
Memcount = Memcount + child.GetHighestRSS() ListOfChildren.append(child)
if child.HasChild(): child.GetChildren(lvl + 1)
if lvl == 0:
self.ParentProcTotalMem = Memcount
Memcount = 0
return ListOfChildren
This is a snippit of using a recursive function that walks down a tree of children with children of their own.
Subscribe to:
Post Comments (Atom)
No comments:
Post a Comment