mirror of
https://mau.dev/maunium/synapse.git
synced 2024-12-18 10:14:08 +01:00
Add comments to explain why we are hardcoding RUSAGE_THREAD
This commit is contained in:
parent
d6059bdd2a
commit
5231737369
1 changed files with 8 additions and 0 deletions
|
@ -21,12 +21,20 @@ logger = logging.getLogger(__name__)
|
||||||
|
|
||||||
try:
|
try:
|
||||||
import resource
|
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
|
RUSAGE_THREAD = 1
|
||||||
|
|
||||||
|
# If the system doesn't support RUSAGE_THREAD then this should throw an
|
||||||
|
# exception.
|
||||||
resource.getrusage(RUSAGE_THREAD)
|
resource.getrusage(RUSAGE_THREAD)
|
||||||
|
|
||||||
def get_thread_resource_usage():
|
def get_thread_resource_usage():
|
||||||
return resource.getrusage(RUSAGE_THREAD)
|
return resource.getrusage(RUSAGE_THREAD)
|
||||||
except:
|
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():
|
def get_thread_resource_usage():
|
||||||
return None
|
return None
|
||||||
|
|
||||||
|
|
Loading…
Reference in a new issue