Skip to content

Instantly share code, notes, and snippets.

@andkon
Last active August 29, 2015 14:01
Show Gist options
  • Save andkon/2ca50032e7a0a725d353 to your computer and use it in GitHub Desktop.
Save andkon/2ca50032e7a0a725d353 to your computer and use it in GitHub Desktop.
Python-Django debugging with Foreman/gunicorn/celery.
# 1. Use Celery:
# http://celery.readthedocs.org/en/latest/tutorials/debugging.html
from celery import task
from celery.contrib import rdb
@task()
def add(x, y):
result = x + y
rdb.set_trace() # <- set breakpoint
return result
# Then telnet in:
telnet 127.0.0.1 6900
# then you're into PDB.
# 2. Use sys.stdout.flush() to get gunicorn to print
import sys
print "After every print line, you need to put sys.stdout.flush()"
sys.stdout.flush()
# "After every print line, you need to put sys.stdout.flush()"
# 3. amp up the log levels on foreman:
web: gunicorn Strings.wsgi --log-level debug
celery: celery worker -A Strings -l debug -c 2
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment