Skip to content

Commit 0e53367

Browse files
committed
Fix for issue #101
1 parent fe77c9b commit 0e53367

1 file changed

Lines changed: 7 additions & 2 deletions

File tree

memory_profiler.py

Lines changed: 7 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -51,8 +51,13 @@ def _get_memory(pid, timestamps=False, include_children=False):
5151
meminfo_attr = 'memory_info' if hasattr(process, 'memory_info') else 'get_memory_info'
5252
mem = getattr(process, meminfo_attr)()[0] / _TWO_20
5353
if include_children:
54-
for p in process.get_children(recursive=True):
55-
mem += getattr(process, meminfo_attr)()[0] / _TWO_20
54+
try:
55+
for p in process.get_children(recursive=True):
56+
mem += getattr(process, meminfo_attr)()[0] / _TWO_20
57+
except AttributeError:
58+
# fix for newer psutil
59+
for p in process.children(recursive=True):
60+
mem += getattr(process, meminfo_attr)()[0] / _TWO_20
5661
if timestamps:
5762
return (mem, time.time())
5863
else:

0 commit comments

Comments
 (0)