Index: tools/telemetry/telemetry/core/platform/tracing_agent/chrome_tracing_agent.py |
diff --git a/tools/telemetry/telemetry/core/platform/tracing_agent/chrome_tracing_agent.py b/tools/telemetry/telemetry/core/platform/tracing_agent/chrome_tracing_agent.py |
index b3bb05d7eff57831d166e7ccf1bae438edbda67e..81cf267af52583eca9ab7a6a79ad957db36e878a 100644 |
--- a/tools/telemetry/telemetry/core/platform/tracing_agent/chrome_tracing_agent.py |
+++ b/tools/telemetry/telemetry/core/platform/tracing_agent/chrome_tracing_agent.py |
@@ -1,6 +1,8 @@ |
# Copyright 2014 The Chromium Authors. All rights reserved. |
# Use of this source code is governed by a BSD-style license that can be |
# found in the LICENSE file. |
+import sys |
+import traceback |
from telemetry.core.platform import tracing_agent |
@@ -9,6 +11,10 @@ class ChromeTracingStartedError(Exception): |
pass |
+class ChromeTracingStoppedError(Exception): |
+ pass |
+ |
+ |
class ChromeTracingAgent(tracing_agent.TracingAgent): |
# A singleton map from platform backends to maps of uniquely-identifying |
# remote port (which may be the same as local port) to DevToolsClientBackend. |
@@ -90,9 +96,21 @@ class ChromeTracingAgent(tracing_agent.TracingAgent): |
def Stop(self, trace_data_builder): |
devtools_clients_map = ( |
self._platform_backends_to_devtools_clients_maps[self._platform_backend]) |
- for _, devtools_client in devtools_clients_map.iteritems(): |
+ raised_execption_messages = [] |
+ for devtools_port, devtools_client in devtools_clients_map.iteritems(): |
# We do not check for stale DevTools client, so that we get an |
# exception if there is a stale client. This is because we |
# will potentially lose data if there is a stale client. |
- devtools_client.StopChromeTracing(trace_data_builder) |
+ try: |
+ devtools_client.StopChromeTracing(trace_data_builder) |
+ except Exception: |
+ raised_execption_messages.append( |
+ 'Error when trying to stop tracing on devtools at port %s:\n%s' |
+ % (devtools_port, |
+ ''.join(traceback.format_exception(*sys.exc_info())))) |
+ |
self._is_active = False |
+ if raised_execption_messages: |
+ raise ChromeTracingStoppedError( |
+ 'Exceptions raised when trying to stop devtool tracing\n:' + |
+ '\n'.join(raised_execption_messages)) |