Commit 2f15d8ba authored by dtu@chromium.org's avatar dtu@chromium.org

[telemetry] Terminate process and close handle on IPPET failure.

Continuation of https://chromiumcodereview.appspot.com/444013002/


BUG=400960
TEST=python tools/telemetry/run_tests ippet

Review URL: https://codereview.chromium.org/444163002

git-svn-id: svn://svn.chromium.org/chrome/trunk/src@287941 0039d316-1c4b-4281-b951-d872f2087c98
parent 61a36729
...@@ -126,25 +126,31 @@ class IppetPowerMonitor(power_monitor.PowerMonitor): ...@@ -126,25 +126,31 @@ class IppetPowerMonitor(power_monitor.PowerMonitor):
assert self._ippet_handle, ( assert self._ippet_handle, (
'Called StopMonitoringPower() before StartMonitoringPower().') 'Called StopMonitoringPower() before StartMonitoringPower().')
# Stop IPPET. # Stop IPPET.
ippet_quit_url = 'http://127.0.0.1:%d/ippet?cmd=quit' % self._ippet_port try:
quit_output = urllib2.urlopen(ippet_quit_url).read() ippet_quit_url = 'http://127.0.0.1:%d/ippet?cmd=quit' % self._ippet_port
if quit_output != 'quiting\r\n': quit_output = urllib2.urlopen(ippet_quit_url).read()
raise IppetError('Failed to quit IPPET: %s' % quit_output.strip()) if quit_output != 'quiting\r\n':
wait_return_code = win32event.WaitForSingleObject(self._ippet_handle, 20000) raise IppetError('Failed to quit IPPET: %s' % quit_output.strip())
if wait_return_code != win32event.WAIT_OBJECT_0: wait_return_code = win32event.WaitForSingleObject(self._ippet_handle,
if wait_return_code == win32event.WAIT_TIMEOUT: 20000)
raise IppetError('Timed out waiting for IPPET to close.') if wait_return_code != win32event.WAIT_OBJECT_0:
else: if wait_return_code == win32event.WAIT_TIMEOUT:
raise IppetError('Error code %d while waiting for IPPET to close.' % raise IppetError('Timed out waiting for IPPET to close.')
wait_return_code) else:
ippet_exit_code = win32process.GetExitCodeProcess(self._ippet_handle) raise IppetError('Error code %d while waiting for IPPET to close.' %
if ippet_exit_code == win32con.STILL_ACTIVE: wait_return_code)
raise IppetError('IPPET is still running but should have stopped.') finally:
elif ippet_exit_code != 0: try:
raise IppetError('IPPET closed with exit code %d.' % ippet_exit_code) ippet_exit_code = win32process.GetExitCodeProcess(self._ippet_handle)
self._ippet_handle.Close() if ippet_exit_code == win32con.STILL_ACTIVE:
self._ippet_handle = None win32process.TerminateProcess(self._ippet_handle)
self._ippet_port = None 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. # Read IPPET's log file.
log_file = os.path.join(self._output_dir, 'ippet_log_processes.xls') log_file = os.path.join(self._output_dir, 'ippet_log_processes.xls')
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment