From 04dd61bead8b4d55d31c00befe9ed7da4c615943 Mon Sep 17 00:00:00 2001 From: Adam Palay Date: Wed, 18 May 2016 12:52:04 -0400 Subject: [PATCH] remove logging --- .../xmodule/modulestore/split_mongo/split.py | 25 ------------------- .../tests/test_split_modulestore.py | 18 +------------ 2 files changed, 1 insertion(+), 42 deletions(-) diff --git a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py index 25b3a7d525..72b65596d2 100644 --- a/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py +++ b/common/lib/xmodule/xmodule/modulestore/split_mongo/split.py @@ -62,7 +62,6 @@ from importlib import import_module from mongodb_proxy import autoretry_read from path import Path as path from pytz import UTC -import traceback from bson.objectid import ObjectId from xblock.core import XBlock @@ -688,10 +687,6 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase): if self.request_cache is not None: self.services["request_cache"] = self.request_cache - # set the maximum number of courses we expect - # to see in the request cache - self.max_num_courses_in_cache = 10 - self.signal_handler = signal_handler def close_connections(self): @@ -800,26 +795,6 @@ class SplitMongoModuleStore(SplitBulkWriteMixin, ModuleStoreWriteBase): """ if self.request_cache is not None: self.request_cache.data.setdefault('course_cache', {})[course_version_guid] = system - number_courses_in_cache = len(self.request_cache.data['course_cache']) - if number_courses_in_cache > self.max_num_courses_in_cache: - # We shouldn't have any scenarios where there are many - # courses in the request cache. If there are, it's probably - # indicative of a leak. In this case, we should log that here - # with a stacktrace. - course_structure_ids = self.request_cache.data['course_cache'].keys()[:10] - log.warning( - ( - "There are more than %d (%d) " - "courses in the request cache. This may be indicative " - "of a memory leak.\n\nHere are some of the course " - "structures' mongo ids that are now in the cache: %s\n\n" - "And here's the current stack:\n%s" - ), - self.max_num_courses_in_cache, - number_courses_in_cache, - ", ".join(unicode(structure_id) for structure_id in course_structure_ids), - "".join(traceback.format_stack()[-10:]) - ) return system def _clear_cache(self, course_version_guid=None): diff --git a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py index 05f317bd18..a1649dd8b2 100644 --- a/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py +++ b/common/lib/xmodule/xmodule/modulestore/tests/test_split_modulestore.py @@ -1,7 +1,7 @@ """ Test split modulestore w/o using any django stuff. """ -from mock import patch, Mock +from mock import patch import datetime from importlib import import_module from path import Path as path @@ -627,22 +627,6 @@ class SplitModuleCourseTests(SplitModuleTest): self.assertEqual(course.edited_by, "testassist@edx.org") self.assertDictEqual(course.grade_cutoffs, {"Pass": 0.45}) - @ddt.data((10, 0), (2, 1)) - @ddt.unpack - @patch("xmodule.modulestore.split_mongo.split.log.warning") - def test_request_cache_max_courses(self, max_courses, expected_warnings, mock_log): - """ - Test that we warn if there are too many courses in the request cache - at once. - """ - mock_request_cache = Mock() - mock_request_cache.data = {} - - modulestore().max_num_courses_in_cache = max_courses - modulestore().request_cache = mock_request_cache - modulestore().get_courses(branch=BRANCH_NAME_DRAFT) - self.assertEqual(mock_log.call_count, expected_warnings) - @patch('xmodule.tabs.CourseTab.from_json', side_effect=mock_tab_from_json) def test_get_courses_with_same_course_index(self, _from_json): """