Last active
September 21, 2016 04:01
-
-
Save ssanderson/a089b30b5c9fecec50526a0e54878678 to your computer and use it in GitHub Desktop.
More Machete Mode Debugging
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import os | |
from unittest import TestCase | |
import psutil | |
import humanize | |
pid = os.getpid() | |
proc = psutil.Process(pid) | |
real_doCleanups = TestCase.doCleanups | |
OUTPUT_FILE = open('/home/ssanderson/pandas16_memory_usage.txt', 'w') | |
def get_mem_usage(): | |
return humanize.naturalsize(proc.memory_full_info().uss) | |
def patched_doCleanups(self, *args, **kwargs): | |
OUTPUT_FILE.write("{} {}\n".format(get_mem_usage(), self)) | |
OUTPUT_FILE.flush() | |
return real_doCleanups(self, *args, **kwargs) | |
TestCase.doCleanups = patched_doCleanups |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment