The python documentation defines a global constant named __debug__ :
__debug__
This constant is true if Python was not started with an -O option. See also the assert statement.
I'm using some python library under 开发者_开发百科my production Django site (Apache/WSGI based) which checks this constant before executing debug-only code.To my surprise, that code is being executed in production.
As the Django site was not started via the python command line interperter, I was wondering what controls this __deubg__ constant?
Looks like you can use the PYTHONOPTIMIZE environment variable. You may need to set it from your apache configuration... Not too sure I haven't used the standard WSGI setup in a long time.
For the sake of all who follow, this is the wsgi directive you are looking for: WSGIPythonOptimize
The documentation states:
The default is '0' which means no optimisations are applied.
So in the default case __debug__
would be True
.
Is settings.DEBUG
set to False
?
精彩评论