diff options
author | Richard van der Hoff <richard@matrix.org> | 2019-09-24 12:57:32 +0100 |
---|---|---|
committer | Richard van der Hoff <richard@matrix.org> | 2019-09-24 12:57:32 +0100 |
commit | ed8b92f0d22b9de96c5ac04ef8ef45531fe45a2c (patch) | |
tree | c6c35d841e75d73ed2a045d30d8abc87487a57ab /synapse/logging | |
parent | Merge commit '33757bad1' into rav/saml_mapping_work (diff) | |
parent | Add submit_url response parameter to msisdn /requestToken (#6079) (diff) | |
download | synapse-ed8b92f0d22b9de96c5ac04ef8ef45531fe45a2c.tar.xz |
Merge remote-tracking branch 'origin/develop' into rav/saml_mapping_work
Diffstat (limited to 'synapse/logging')
-rw-r--r-- | synapse/logging/context.py | 13 |
1 files changed, 11 insertions, 2 deletions
diff --git a/synapse/logging/context.py b/synapse/logging/context.py index 63379bfb93..370000e377 100644 --- a/synapse/logging/context.py +++ b/synapse/logging/context.py @@ -1,4 +1,5 @@ # Copyright 2014-2016 OpenMarket Ltd +# Copyright 2019 The Matrix.org Foundation C.I.C. # # Licensed under the Apache License, Version 2.0 (the "License"); # you may not use this file except in compliance with the License. @@ -42,13 +43,17 @@ try: # exception. resource.getrusage(RUSAGE_THREAD) + is_thread_resource_usage_supported = True + def get_thread_resource_usage(): return resource.getrusage(RUSAGE_THREAD) except Exception: # If the system doesn't support resource.getrusage(RUSAGE_THREAD) then we - # won't track resource usage by returning None. + # won't track resource usage. + is_thread_resource_usage_supported = False + def get_thread_resource_usage(): return None @@ -359,7 +364,11 @@ class LoggingContext(object): # When we stop, let's record the cpu used since we started if not self.usage_start: - logger.warning("Called stop on logcontext %s without calling start", self) + # Log a warning on platforms that support thread usage tracking + if is_thread_resource_usage_supported: + logger.warning( + "Called stop on logcontext %s without calling start", self + ) return utime_delta, stime_delta = self._get_cputime() |