Gunicorn: Can I use pdb with gunicorn to inspect what is happening in my webapp?

Created on 25 Mar 2011  路  3Comments  路  Source: benoitc/gunicorn

Apparently, with cherrypy, you can add pdb.settrace() in the middle of your app code, and then in the terminal where you started cherrypy, after you hit that code in your browser, you can then walk around and inspect stuff.

I just heard about this; I haven't seen it first-hand. But I know that similar stuff exists in .NET and other frameworks.

Could something like this be set up in gunicorn? How?

Most helpful comment

I stumbled upon this issue and thought I would share the config file I use to do this:

gunicorn_logfile = "/dev/null"
gunicorn_loglevel = "error"

debug = True
timeout = 900000
workers = 1
worker_class = "sync"

Throwing down a pdb.set_trace() then works with either pdbpp or pdb without the debugger getting mixed up with stdout.

All 3 comments

Easiest method would be to do your pdb configuration in the post_fork hook while using a single sync worker.

If you find something that doesn't actually work, feel free to reopen this.

I stumbled upon this issue and thought I would share the config file I use to do this:

gunicorn_logfile = "/dev/null"
gunicorn_loglevel = "error"

debug = True
timeout = 900000
workers = 1
worker_class = "sync"

Throwing down a pdb.set_trace() then works with either pdbpp or pdb without the debugger getting mixed up with stdout.

That timeout thing was just what I was looking for. Thanks!

Was this page helpful?
0 / 5 - 0 ratings

Related issues

zenglingyu picture zenglingyu  路  4Comments

ttcqaq picture ttcqaq  路  4Comments

davidfstr picture davidfstr  路  3Comments

gr790 picture gr790  路  4Comments

twosigmajab picture twosigmajab  路  4Comments