From 6e34c367dff80dfce3a7e689afdfd241d18a0ac5 Mon Sep 17 00:00:00 2001 From: Ilya Gotfyrd Date: Thu, 10 May 2018 13:26:05 -0400 Subject: [PATCH] correction on default value evaluated --- turbogears/memory_profiler_setup.py | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/turbogears/memory_profiler_setup.py b/turbogears/memory_profiler_setup.py index 424c51b..aa7a731 100644 --- a/turbogears/memory_profiler_setup.py +++ b/turbogears/memory_profiler_setup.py @@ -31,6 +31,7 @@ class MemoryProfilerState(Enum): '{}/turbogears_memory_profiler'.format(tempfile.gettempdir())) TURBOGEARS_PROFILER_FIFO_NAME = os.environ.get('TURBOGEARS_PROFILER_FIFO_NAME', 'turbogears_memory_config_fifo_{}') TURBOGEARS_PROFILER_LOG_TO_CONSOLE = os.environ.get('TURBOGEARS_PROFILER_LOG_TO_CONSOLE', 'False') == 'True' +TURBOGEARS_PROFILER_ACTIVATE = os.environ.get('TURBOGEARS_PROFILER_ACTIVATE', 'False') == 'True' # setup thread log handler to monitor state of memory profile logging thread_log = logging.getLogger("memory_profiler_thread_log") @@ -69,8 +70,6 @@ class MemoryProfilerState(Enum): ) - - def toggle_memory_profile_via_fifo(_thread_log): """ Execution body of a thread that monitors any input on a named pipe located at @@ -224,6 +223,10 @@ def _parse_pympler_command(command_args): def create_config_thread(_thread_log): + if not TURBOGEARS_PROFILER_ACTIVATE: + _thread_log.info("TURBOGEARS_PROFILER deactivated, add TURBOGEARS_PROFILER_ACTIVATE=True " + "to activate it in this environment.") + return None # start configuration pipe monitoring thread on import _config_thread = threading.Thread(target=toggle_memory_profile_via_fifo, args=(_thread_log,), name='toggle_memory_profile_via_fifo')