From 175a33ff3c92fdc5bd30de397b139c749d926e66 Mon Sep 17 00:00:00 2001 From: Pale Moon Date: Tue, 17 Oct 2017 11:31:12 +0200 Subject: [PATCH] Convert resourcemonitor poll() to float, and break the loop immediately when done. --- .../mozsystemmonitor/resourcemonitor.py | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-) diff --git a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py index dd2d8f4486..bf6d898b7f 100644 --- a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py +++ b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py @@ -256,13 +256,19 @@ class SystemResourceMonitor(object): done = False - while self._pipe.poll(1): + # The child process will send each data sample over the pipe + # as a separate data structure. When it has finished sending + # samples, it sends a special "done" message to indicate it + # is finished. + while self._pipe.poll(1.0): start_time, end_time, io_diff, cpu_diff, cpu_percent, virt_mem, \ swap_mem = self._pipe.recv() + # There should be nothing after the "done" message so + # terminate. if start_time == 'done': done = True - continue + break io = self._io_type(*io_diff) virt = self._virt_type(*virt_mem)