mirror of
https://git.anonymousland.org/anonymousland/synapse.git
synced 2025-08-02 08:46:01 -04:00
Make psutil optional
This commit is contained in:
parent
f5deaff424
commit
7c1a92274c
3 changed files with 16 additions and 6 deletions
|
@ -68,9 +68,18 @@ class Metrics(object):
|
|||
|
||||
|
||||
def register_memory_metrics(hs):
|
||||
metric = MemoryUsageMetric(hs)
|
||||
try:
|
||||
import psutil
|
||||
process = psutil.Process()
|
||||
process.memory_info().rss
|
||||
except (ImportError, AttributeError):
|
||||
logger.warn(
|
||||
"psutil is not installed or incorrect version."
|
||||
" Disabling memory metrics."
|
||||
)
|
||||
return
|
||||
metric = MemoryUsageMetric(hs, psutil)
|
||||
all_metrics.append(metric)
|
||||
return metric
|
||||
|
||||
|
||||
def get_metrics_for(pkg_name):
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue