Skip to content

Commit

Permalink
Merge pull request #17 from ilyaGotfryd/NT-159-activate-memory-profil…
Browse files Browse the repository at this point in the history
…ing-with-environment-variable

NT-159 correction on default value evaluated
  • Loading branch information
jasonflorack authored May 10, 2018
2 parents f3d3ac9 + 6e34c36 commit b5420cb
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions turbogears/memory_profiler_setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -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")
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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')
Expand Down

0 comments on commit b5420cb

Please sign in to comment.