Handle disappearing pids in mlock_report.py
If a pid disappears on us while we're reading, we should just continue on. EnvironmentError is just an alias for OSError since Python 3.3, so use the latter name. [0] [0] https://docs.python.org/3/library/exceptions.html#OSError Change-Id: I3a25cca328e1469f72c84a118a9691c1c0258bc4 Closes-Bug: #1926434
This commit is contained in:
parent
c062792709
commit
b02a43291c
@ -24,8 +24,6 @@ def _get_report():
|
|||||||
# iterate over the /proc/%pid/status files manually
|
# iterate over the /proc/%pid/status files manually
|
||||||
try:
|
try:
|
||||||
s = open("%s/%d/status" % (psutil.PROCFS_PATH, proc.pid), 'r')
|
s = open("%s/%d/status" % (psutil.PROCFS_PATH, proc.pid), 'r')
|
||||||
except EnvironmentError:
|
|
||||||
continue
|
|
||||||
with s:
|
with s:
|
||||||
for line in s:
|
for line in s:
|
||||||
result = LCK_SUMMARY_REGEX.search(line)
|
result = LCK_SUMMARY_REGEX.search(line)
|
||||||
@ -35,6 +33,10 @@ def _get_report():
|
|||||||
mlock_users.append({'name': proc.name(),
|
mlock_users.append({'name': proc.name(),
|
||||||
'pid': proc.pid,
|
'pid': proc.pid,
|
||||||
'locked': locked})
|
'locked': locked})
|
||||||
|
except OSError:
|
||||||
|
# pids can disappear, we're ok with that
|
||||||
|
continue
|
||||||
|
|
||||||
|
|
||||||
# produce a single line log message with per process mlock stats
|
# produce a single line log message with per process mlock stats
|
||||||
if mlock_users:
|
if mlock_users:
|
||||||
|
Loading…
Reference in New Issue
Block a user