From e94e1978be0ba29b0404797278b045f0b30071ae Mon Sep 17 00:00:00 2001 From: Chris Church Date: Tue, 4 Feb 2014 23:04:58 -0500 Subject: [PATCH] Disable capturing SQL queries in memory when running celeryd in development. --- awx/__init__.py | 5 +++++ awx/settings/defaults.py | 1 + awx/settings/development.py | 4 ++++ awx/settings/production.py | 1 + 4 files changed, 11 insertions(+) diff --git a/awx/__init__.py b/awx/__init__.py index 5633508baa..1729f32d59 100644 --- a/awx/__init__.py +++ b/awx/__init__.py @@ -64,6 +64,11 @@ def prepare_env(): for opt in ('ENGINE', 'NAME', 'USER', 'PASSWORD', 'HOST', 'PORT'): if os.environ.get('AWX_TEST_DATABASE_%s' % opt, None): settings.DATABASES['default'][opt] = os.environ['AWX_TEST_DATABASE_%s' % opt] + # Disable capturing all SQL queries in memory when in DEBUG mode. + if settings.DEBUG and not getattr(settings, 'SQL_DEBUG', True): + from django.db.backends import BaseDatabaseWrapper + from django.db.backends.util import CursorWrapper + BaseDatabaseWrapper.make_debug_cursor = lambda self, cursor: CursorWrapper(cursor, self) def manage(): # Prepare the AWX environment. diff --git a/awx/settings/defaults.py b/awx/settings/defaults.py index fca79f1480..77a94c5b89 100644 --- a/awx/settings/defaults.py +++ b/awx/settings/defaults.py @@ -16,6 +16,7 @@ BASE_DIR = os.path.dirname(os.path.dirname(__file__)) DEBUG = True TEMPLATE_DEBUG = DEBUG +SQL_DEBUG = DEBUG ADMINS = ( # ('Your Name', 'your_email@domain.com'), diff --git a/awx/settings/development.py b/awx/settings/development.py index 99011b5bb0..a19b0e8a88 100644 --- a/awx/settings/development.py +++ b/awx/settings/development.py @@ -13,6 +13,10 @@ from split_settings.tools import optional, include # Load default settings. from defaults import * +# Disable capturing all SQL queries when running celeryd in development. +if 'celeryd' in sys.argv: + SQL_DEBUG = False + # If any local_*.py files are present in awx/settings/, use them to override # default settings for development. If not present, we can still run using # only the defaults. diff --git a/awx/settings/production.py b/awx/settings/production.py index 7af5eda6cb..5299d9c84b 100644 --- a/awx/settings/production.py +++ b/awx/settings/production.py @@ -15,6 +15,7 @@ from defaults import * DEBUG = False TEMPLATE_DEBUG = DEBUG +SQL_DEBUG = DEBUG # Clear database settings to force production environment to define them. DATABASES = {}