From 50aa37be57fb89906f497eebe62c77afbb3766dc Mon Sep 17 00:00:00 2001 From: Ned Batchelder Date: Tue, 1 Oct 2013 18:13:06 -0400 Subject: [PATCH] Quiet down exceptions at startup, and during tests There's no need to display a traceback for every failed content load, the comment before the log line even says so. The exceptions shown before tests are run are because of the eager initialization of the modulestores. They don't need to be initialized then, that just speeds the responsiveness of servers. Putting off the initialization means they get inited as needed, and the log lines get --- common/lib/xmodule/xmodule/modulestore/xml.py | 2 +- lms/envs/common.py | 4 ++++ lms/envs/test.py | 4 ++++ lms/startup.py | 9 +++++---- 4 files changed, 14 insertions(+), 5 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/xml.py b/common/lib/xmodule/xmodule/modulestore/xml.py index da86279b68..a8e9da03d7 100644 --- a/common/lib/xmodule/xmodule/modulestore/xml.py +++ b/common/lib/xmodule/xmodule/modulestore/xml.py @@ -179,7 +179,7 @@ class ImportSystem(XMLParsingSystem, MakoDescriptorSystem): # Normally, we don't want lots of exception traces in our logs from common # content problems. But if you're debugging the xml loading code itself, # uncomment the next line. - log.exception(msg) + # log.exception(msg) self.error_tracker(msg) err_msg = msg + "\n" + exc_info_to_str(sys.exc_info()) diff --git a/lms/envs/common.py b/lms/envs/common.py index 96b304294d..0d4b6ec8a8 100644 --- a/lms/envs/common.py +++ b/lms/envs/common.py @@ -363,6 +363,10 @@ MODULESTORE = { } CONTENTSTORE = None +# Should we initialize the modulestores at startup, or wait until they are +# needed? +INIT_MODULESTORE_ON_STARTUP = True + ############# XBlock Configuration ########## # This should be moved into an XBlock Runtime/Application object diff --git a/lms/envs/test.py b/lms/envs/test.py index f79c8c4218..0951601ec7 100644 --- a/lms/envs/test.py +++ b/lms/envs/test.py @@ -110,6 +110,10 @@ MODULESTORE = { } } +# Starting modulestores generates log messages. If we wait to init modulestores, +# then those messages will be silenced by the test runner. +INIT_MODULESTORE_ON_STARTUP = False + CONTENTSTORE = { 'ENGINE': 'xmodule.contentstore.mongo.MongoContentStore', 'OPTIONS': { diff --git a/lms/startup.py b/lms/startup.py index 6837383130..ead831600d 100644 --- a/lms/startup.py +++ b/lms/startup.py @@ -19,7 +19,8 @@ def run(): """ autostartup() - # trigger a forced initialization of our modulestores since this can take a while to complete - # and we want this done before HTTP requests are accepted - for store_name in settings.MODULESTORE: - modulestore(store_name) + # Trigger a forced initialization of our modulestores since this can take a while to complete + # and we want this done before HTTP requests are accepted. + if settings.INIT_MODULESTORE_ON_STARTUP: + for store_name in settings.MODULESTORE: + modulestore(store_name)