Bug 1272782 - Don't wait forever for child process to exit; r?ahal draft
authorGregory Szorc <gps@mozilla.com>
Fri, 13 May 2016 14:10:39 -0700
changeset 366989 8f680eab4f03f16eda188fd130e21fb85a2d016c
parent 366988 80987e39d92cf780d30902c7cbaf54827a7408d7
child 366990 21aefbb06de1ba284d12ba3db67aa6855b5d0854
push id18105
push userbmo:gps@mozilla.com
push dateFri, 13 May 2016 21:11:59 +0000
reviewersahal
bugs1272782
milestone49.0a1
Bug 1272782 - Don't wait forever for child process to exit; r?ahal I believe this is the source of hangs/timeouts in automation. join() waits forever. We add code to wait at most N seconds before force terminating the process. The timeout is a bit high. But it is better than infinite. MozReview-Commit-ID: KwyO4RZ9OqL
testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py
--- a/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py
+++ b/testing/mozbase/mozsystemmonitor/mozsystemmonitor/resourcemonitor.py
@@ -307,18 +307,27 @@ class SystemResourceMonitor(object):
             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._process.join()
-        assert done
+        # We establish a timeout so we don't hang forever if the child
+        # process has crashed.
+        self._process.join(10)
+        if self._process.is_alive():
+            self._process.terminate()
+            self._process.join(10)
+        else:
+            # We should have received a "done" message from the
+            # child indicating it shut down properly. This only
+            # happens if the child shuts down cleanly.
+            assert done
 
         if len(self.measurements):
             self.start_time = self.measurements[0].start
             self.end_time = self.measurements[-1].end
 
     # Methods to record events alongside the monitored data.
 
     def record_event(self, name):