summary refs log tree commit diff
path: root/synapse/util
diff options
context:
space:
mode:
authorMark Haines <mark.haines@matrix.org>2015-12-04 11:53:38 +0000
committerMark Haines <mark.haines@matrix.org>2015-12-04 11:53:38 +0000
commit5231737369c6c5488cdfdcb76af8008fc8a2db07 (patch)
tree72405b0380b730657bb0b0f3bc1a6ccd4c7e4096 /synapse/util
parentFix warnings (diff)
downloadsynapse-5231737369c6c5488cdfdcb76af8008fc8a2db07.tar.xz
Add comments to explain why we are hardcoding RUSAGE_THREAD
Diffstat (limited to 'synapse/util')
-rw-r--r--synapse/util/logcontext.py8
1 files changed, 8 insertions, 0 deletions
diff --git a/synapse/util/logcontext.py b/synapse/util/logcontext.py
index 2633201528..e4ce087afe 100644
--- a/synapse/util/logcontext.py
+++ b/synapse/util/logcontext.py
@@ -21,12 +21,20 @@ logger = logging.getLogger(__name__)
 
 try:
     import resource
+
+    # Python doesn't ship with a definition of RUSAGE_THREAD but it's defined
+    # to be 1 on linux so we hard code it.
     RUSAGE_THREAD = 1
+
+    # If the system doesn't support RUSAGE_THREAD then this should throw an
+    # exception.
     resource.getrusage(RUSAGE_THREAD)
 
     def get_thread_resource_usage():
         return resource.getrusage(RUSAGE_THREAD)
 except:
+    # If the system doesn't support resource.getrusage(RUSAGE_THREAD) then we
+    # won't track resource usage by returning None.
     def get_thread_resource_usage():
         return None