Skip to content

Instantly share code, notes, and snippets.

@johncosta
Forked from jpetazzo/README.md
Created November 30, 2012 22:09
Show Gist options
  • Save johncosta/4179055 to your computer and use it in GitHub Desktop.
Save johncosta/4179055 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