Last active
August 29, 2015 14:01
-
-
Save andkon/2ca50032e7a0a725d353 to your computer and use it in GitHub Desktop.
Python-Django debugging with Foreman/gunicorn/celery.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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