Skip to content

Commit d2e3f5f

Browse files
authored
Merge pull request carbonblack#78 from carbonblack/development
Add `.parents` property to `Process` model
2 parents e42c93e + 132ea42 commit d2e3f5f

File tree

1 file changed

+10
-8
lines changed

1 file changed

+10
-8
lines changed

src/cbapi/response/models.py

Lines changed: 10 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -2334,15 +2334,17 @@ def crossprocs(self):
23342334

23352335
@property
23362336
def parents(self):
2337-
try:
2338-
parent_proc = self.parent
2339-
while parent_proc and parent_proc.id and parent_proc.get("process_pid", -1) != -1:
2340-
yield parent_proc
2341-
parent_proc = parent_proc.parent
2342-
except:
2337+
current_process = self
2338+
while True:
2339+
try :
2340+
parent = current_process.parent
2341+
if not(parent) or parent.get('process_pid',-1) == -1:
2342+
break
2343+
yield parent
2344+
current_process = parent
2345+
except ObjectNotFoundError:
2346+
return
23432347
return
2344-
return
2345-
23462348
@property
23472349
def children(self):
23482350
"""

0 commit comments

Comments
 (0)