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.
相关问题
- how to define constructor for Python's new Nam
- streaming md5sum of contents of a large remote tar
- How to get the background from multiple images by
- Django __str__ returned non-string (type NoneType)
- Evil ctypes hack in python
Building off of asksol's answer (https://stackoverflow.com/a/4806384/3009897) in light of sww314's comment on that answer, that the indicated method does not work in Celery 4.x, one can instead rely on the inspect module to determine the execution stack that the DEBUG setting is being accessed in.
For my purposes, the following change worked:
This assumes that the outermost invocation frame will include the string 'celery' in the associated filepath. (The check for DEBUG is a stab at ensuring that if this is left in place for production (where DEBUG = False should be set), the inspect shouldn't take place.)
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: