Skip to content

Commit

Permalink
Catch psutil.AccessDenied
Browse files Browse the repository at this point in the history
Signed-off-by: Zack Cerza <[email protected]>
  • Loading branch information
zmc committed Jul 26, 2024
1 parent 016b935 commit f453952
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 3 deletions.
5 changes: 4 additions & 1 deletion teuthology/dispatcher/__init__.py
Original file line number Diff line number Diff line change
Expand Up @@ -222,7 +222,10 @@ def match(proc):
procs = {}
attrs = ["pid", "cmdline"]
for proc in psutil.process_iter(attrs=attrs):
if not match(proc):
try:
if not match(proc):
continue
except psutil.AccessDenied:
continue
cmdline = proc.cmdline()
machine_type = cmdline[cmdline.index("--tube") + 1]
Expand Down
7 changes: 5 additions & 2 deletions teuthology/exporter.py
Original file line number Diff line number Diff line change
Expand Up @@ -138,8 +138,11 @@ def update(self):
attrs = ["pid", "cmdline"]
total = 0
for proc in psutil.process_iter(attrs=attrs):
if self._match(proc):
total += 1
try:
if self._match(proc):
total += 1
except psutil.AccessDenied:
pass
self.metric.set(total)

@staticmethod
Expand Down

0 comments on commit f453952

Please sign in to comment.