Use variable instead of function

This commit is contained in:
J. Ryan Stinnett 2019-09-18 21:33:35 +01:00
parent 5d4d1ad77e
commit ef0281a97d

View file

@ -43,8 +43,7 @@ try:
# exception. # exception.
resource.getrusage(RUSAGE_THREAD) resource.getrusage(RUSAGE_THREAD)
def is_thread_resource_usage_supported(): is_thread_resource_usage_supported = True
return True
def get_thread_resource_usage(): def get_thread_resource_usage():
return resource.getrusage(RUSAGE_THREAD) return resource.getrusage(RUSAGE_THREAD)
@ -53,8 +52,7 @@ try:
except Exception: except Exception:
# If the system doesn't support resource.getrusage(RUSAGE_THREAD) then we # If the system doesn't support resource.getrusage(RUSAGE_THREAD) then we
# won't track resource usage. # won't track resource usage.
def is_thread_resource_usage_supported(): is_thread_resource_usage_supported = False
return False
def get_thread_resource_usage(): def get_thread_resource_usage():
return None return None
@ -367,8 +365,10 @@ class LoggingContext(object):
# When we stop, let's record the cpu used since we started # When we stop, let's record the cpu used since we started
if not self.usage_start: if not self.usage_start:
# Log a warning on platforms that support thread usage tracking # Log a warning on platforms that support thread usage tracking
if is_thread_resource_usage_supported(): if is_thread_resource_usage_supported:
logger.warning("Called stop on logcontext %s without calling start", self) logger.warning(
"Called stop on logcontext %s without calling start", self
)
return return
utime_delta, stime_delta = self._get_cputime() utime_delta, stime_delta = self._get_cputime()