Chromium Code Reviews| 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 4b33f0b805cc303e53c5b5b0acd8e776e649da52..8f43271332bccfb5f59c625e0d389b2c138fb36b 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 |
| @@ -121,26 +121,28 @@ class IppetPowerMonitor(power_monitor.PowerMonitor): |
| def StopMonitoringPower(self): |
| 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) |
| + 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) |
| + finally: |
| + self._ippet_handle.Close() |
|
dtu
2014/08/06 19:04:22
Closing the handle just releases the reference, it
|
| + 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') |