Skip to content

Conversation

@guillermo-carrasco
Copy link
Contributor

Hi,

With a bit of debugging I found the problem, and a solution for issue #69. It is just a forgotten parameter when creating the object MemTimer when benchmarking external processes.

Also, I noticed that even if psutil module is found, the _get_memory function will calculate the memory twice if os.name == 'posix', which was the case in my Mac OSX. I just put an elif there.

I have tested this fix executing memory_usage on functions that create threads (i.e with multiprocessing.Pool), as well as with functions that call external programs that in turn create several threads (i.e subprocess.check_call).

Hope that helps!

@fabianp
Copy link
Collaborator

fabianp commented Jan 27, 2014

Thanks @guillermo-carrasco! The fix for the issue looks good but I'm not sure about the second fix for os.name == 'posix'. It seems to me that given there's a return inside the if has_psutil it should never get to the next block (unless there's an exception in there, in which case I really want it to step into that block)

@guillermo-carrasco
Copy link
Contributor Author

Ops my bad, you're right. I didn't realise that.

I just discovered what was happening: One of the tests I was doing was calling another script that used memory_usage. This subcall wasn't ran on my virtualenv and therefore psutil was indeed not present.

Should be fine now.

fabianp added a commit that referenced this pull request Jan 28, 2014
Add include_children parameter when creating MemTimer object for external processes
@fabianp fabianp merged commit 3fa7aaf into pythonprofilers:master Jan 28, 2014
@fabianp
Copy link
Collaborator

fabianp commented Jan 28, 2014

Perfect, merged. Thanks!

@guillermo-carrasco
Copy link
Contributor Author

Great, thanks to you!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants