Bug 1861560 - ignore errors when SystemResourceMonitor receives partial incorrect data, r=releng-reviewers,jcristau.

Differential Revision: https://phabricator.services.mozilla.com/D192057
This commit is contained in:
Florian Quèze 2023-10-27 12:23:01 +00:00
parent 42f3b82240
commit e0b6c75e62

View File

@ -377,8 +377,9 @@ class SystemResourceMonitor(object):
virt_mem,
swap_mem,
) = self._pipe.recv()
except Exception:
# Let's assume we're done here
except Exception as e:
warnings.warn("failed to receive data: %s" % e)
# Assume we can't recover
break
# There should be nothing after the "done" message so
@ -386,16 +387,35 @@ class SystemResourceMonitor(object):
if start_time == "done":
break
io = self._io_type(*io_diff)
virt = self._virt_type(*virt_mem)
swap = self._swap_type(*swap_mem)
cpu_times = [self._cpu_times_type(*v) for v in cpu_diff]
try:
io = self._io_type(*io_diff)
virt = self._virt_type(*virt_mem)
swap = self._swap_type(*swap_mem)
cpu_times = [self._cpu_times_type(*v) for v in cpu_diff]
self.measurements.append(
SystemResourceUsage(
start_time, end_time, cpu_times, cpu_percent, io, virt, swap
self.measurements.append(
SystemResourceUsage(
start_time, end_time, cpu_times, cpu_percent, io, virt, swap
)
)
)
except Exception:
# We also can't recover, but output the data that caused the exception
warnings.warn(
"failed to read the received data: %s"
% str(
(
start_time,
end_time,
io_diff,
cpu_diff,
cpu_percent,
virt_mem,
swap_mem,
)
)
)
break
# We establish a timeout so we don't hang forever if the child
# process has crashed.