Skip to content

Instantly share code, notes, and snippets.

@ssanderson
Last active September 21, 2016 04:01
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ssanderson/a089b30b5c9fecec50526a0e54878678 to your computer and use it in GitHub Desktop.
Save ssanderson/a089b30b5c9fecec50526a0e54878678 to your computer and use it in GitHub Desktop.
More Machete Mode Debugging
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