| Index: tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor.py
|
| diff --git a/tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor.py b/tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor.py
|
| index 036fd84ba014cd966efa40263d16d0586f67f848..97c54cd09c727a076c34a2b11b8e57ac4572bde4 100644
|
| --- a/tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor.py
|
| +++ b/tools/telemetry/telemetry/core/platform/power_monitor/ippet_power_monitor.py
|
| @@ -126,25 +126,31 @@ class IppetPowerMonitor(power_monitor.PowerMonitor):
|
| assert self._ippet_handle, (
|
| 'Called StopMonitoringPower() before StartMonitoringPower().')
|
| # Stop IPPET.
|
| - ippet_quit_url = 'http://127.0.0.1:%d/ippet?cmd=quit' % self._ippet_port
|
| - quit_output = urllib2.urlopen(ippet_quit_url).read()
|
| - if quit_output != 'quiting\r\n':
|
| - raise IppetError('Failed to quit IPPET: %s' % quit_output.strip())
|
| - wait_return_code = win32event.WaitForSingleObject(self._ippet_handle, 20000)
|
| - if wait_return_code != win32event.WAIT_OBJECT_0:
|
| - if wait_return_code == win32event.WAIT_TIMEOUT:
|
| - raise IppetError('Timed out waiting for IPPET to close.')
|
| - else:
|
| - raise IppetError('Error code %d while waiting for IPPET to close.' %
|
| - wait_return_code)
|
| - ippet_exit_code = win32process.GetExitCodeProcess(self._ippet_handle)
|
| - if ippet_exit_code == win32con.STILL_ACTIVE:
|
| - raise IppetError('IPPET is still running but should have stopped.')
|
| - elif ippet_exit_code != 0:
|
| - raise IppetError('IPPET closed with exit code %d.' % ippet_exit_code)
|
| - self._ippet_handle.Close()
|
| - self._ippet_handle = None
|
| - self._ippet_port = None
|
| + try:
|
| + ippet_quit_url = 'http://127.0.0.1:%d/ippet?cmd=quit' % self._ippet_port
|
| + quit_output = urllib2.urlopen(ippet_quit_url).read()
|
| + if quit_output != 'quiting\r\n':
|
| + raise IppetError('Failed to quit IPPET: %s' % quit_output.strip())
|
| + wait_return_code = win32event.WaitForSingleObject(self._ippet_handle,
|
| + 20000)
|
| + if wait_return_code != win32event.WAIT_OBJECT_0:
|
| + if wait_return_code == win32event.WAIT_TIMEOUT:
|
| + raise IppetError('Timed out waiting for IPPET to close.')
|
| + else:
|
| + raise IppetError('Error code %d while waiting for IPPET to close.' %
|
| + wait_return_code)
|
| + finally:
|
| + try:
|
| + ippet_exit_code = win32process.GetExitCodeProcess(self._ippet_handle)
|
| + if ippet_exit_code == win32con.STILL_ACTIVE:
|
| + win32process.TerminateProcess(self._ippet_handle)
|
| + raise IppetError('IPPET is still running but should have stopped.')
|
| + elif ippet_exit_code != 0:
|
| + raise IppetError('IPPET closed with exit code %d.' % ippet_exit_code)
|
| + finally:
|
| + self._ippet_handle.Close()
|
| + self._ippet_handle = None
|
| + self._ippet_port = None
|
|
|
| # Read IPPET's log file.
|
| log_file = os.path.join(self._output_dir, 'ippet_log_processes.xls')
|
|
|