Skip to content

Instantly share code, notes, and snippets.

@jpetazzo
Created November 15, 2012 20:52
Show Gist options
  • Save jpetazzo/4081192 to your computer and use it in GitHub Desktop.
Save jpetazzo/4081192 to your computer and use it in GitHub Desktop.
Wrap your WSGI app with Guppy

Edit your wsgi.py file to wrap your application object as shown in the attached example.

Then go to /__guppy__ to see memory usage profiling.

This is very basic and probably needs to be refined.

www:
type: python
def application(environ, start_response):
start_response('200 OK', [('Content-Type', 'text/plain')])
yield 'Hello World\n'
def wrapped_application(environ, start_response):
if environ['REQUEST_URI'] == '/__guppy__':
from guppy import hpy
data = hpy().heap()
start_response('200 OK', [('Content-Type', 'text/plain')])
return [ str(data) ]
else:
return original_application(environ, start_response)
original_application = application
application = wrapped_application
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment