Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Disable Django Debugging for Celery

Is it possible to set DEBUG=False for only a specific app in Django? Celery has a known memory leak when debugging is enabled. I have a development server where I want Celery to run as a service, without debugging so it doesn't leak memory, but I want the rest of my Django app to use debugging so errors will be shown when testing.

like image 646
Cerin Avatar asked Jan 26 '11 15:01

Cerin


People also ask

How do I disable debug in Django?

How do I turn off debug mode? To disable USB Debugging mode: Go to Settings and scroll to the System section (on Android 8 and above, go to Settings > System) Tap Developer Options. Tap the button to toggle developer options Off.

How do you change the Django settings debug to false?

Open your settings.py file (or settings_local.py ) and set DEBUG = False (just add that line if necessary). Turning off the Django debug mode will: Suppress the verbose Django error messages in favor of a standard 404 or 500 error page. You will now find Django error messages printed in your arches.


1 Answers

Celery doesn't have a memory leak, it's how Django works:

When DEBUG is enabled Django appends every executed SQL statement to django.db.connection.queries, this will grow unbounded in a long running process environment.

I guess you could use a hack like:

if "celeryd" in sys.argv:
    DEBUG = False
like image 162
asksol Avatar answered Oct 02 '22 11:10

asksol