From f6924d68df5b05bd3f31d5c02c62c032d7e97b86 Mon Sep 17 00:00:00 2001 From: Guillermo Carrasco Date: Mon, 27 Jan 2014 21:14:30 +0100 Subject: [PATCH 1/2] Add include_children parameter when creating MemTimer object for external processes. Fix #69 --- memory_profiler.py | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/memory_profiler.py b/memory_profiler.py index 305bd79..59b4aeb 100644 --- a/memory_profiler.py +++ b/memory_profiler.py @@ -58,7 +58,7 @@ def _get_memory(pid, timestamps=False, include_children=False): # continue and try to get this from ps # .. scary stuff .. - if os.name == 'posix': + elif os.name == 'posix': warnings.warn("psutil module not found. memory_profiler will be slow") # .. # .. memory usage in MiB .. @@ -216,7 +216,7 @@ def memory_usage(proc=-1, interval=.1, timeout=None, timestamps=False, while True: child_conn, parent_conn = Pipe() # this will store MemTimer's results p = MemTimer(os.getpid(), interval, child_conn, timestamps=timestamps, - max_usage=max_usage) + max_usage=max_usage, include_children=include_children) p.start() parent_conn.recv() # wait until we start getting memory returned = f(*args, **kw) From 3b25886d0a3ec3b089826b42af71ee481cd5bde9 Mon Sep 17 00:00:00 2001 From: Guillermo Carrasco Date: Mon, 27 Jan 2014 22:37:08 +0100 Subject: [PATCH 2/2] return mem avoids entering the next block. This is not en if else case --- memory_profiler.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/memory_profiler.py b/memory_profiler.py index 59b4aeb..70c5fba 100644 --- a/memory_profiler.py +++ b/memory_profiler.py @@ -58,7 +58,7 @@ def _get_memory(pid, timestamps=False, include_children=False): # continue and try to get this from ps # .. scary stuff .. - elif os.name == 'posix': + if os.name == 'posix': warnings.warn("psutil module not found. memory_profiler will be slow") # .. # .. memory usage in MiB ..