Skip to content

Commit 9cb7af8

Browse files
authored
Merge pull request #388 from DSD-DBS/use-contextlib-suppress
chore: Use contextlib.suppress instead of try-except
2 parents bbf3eb1 + 562bcae commit 9cb7af8

File tree

1 file changed

+2
-3
lines changed

1 file changed

+2
-3
lines changed

remote/metrics.py

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33
# SPDX-FileCopyrightText: Copyright DB InfraGO AG and contributors
44
# SPDX-License-Identifier: Apache-2.0
55

6+
import contextlib
67
import datetime
78
import logging
89
import os
@@ -133,12 +134,10 @@ def collect(self) -> t.Iterable[prometheus_client.Metric]:
133134
)
134135

135136
if hasattr(process, "num_fds"):
136-
try:
137+
with contextlib.suppress(psutil.AccessDenied):
137138
process_open_fds_metric.add_metric(
138139
[process.name()], process.num_fds()
139140
)
140-
except psutil.AccessDenied:
141-
pass
142141

143142
yield process_cpu_percent_metric
144143
yield process_memory_usage_metric

0 commit comments

Comments
 (0)