Chromium Code Reviews
chromiumcodereview-hr@appspot.gserviceaccount.com (chromiumcodereview-hr) | Please choose your nickname with Settings | Help | Chromium Project | Gerrit Changes | Sign out
(46)

Unified Diff: tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py

Issue 382833004: Remove StartAsyncDispatchNotifications from inspector_websocket (Closed) Base URL: https://chromium.googlesource.com/chromium/src.git@master
Patch Set: Update default timeout value for StopTracing call to 30s Created 6 years, 5 months ago
Use n/p to move between diff chunks; N/P to move between comments. Draft comments are only viewable by you.
Jump to:
View side-by-side diff with in-line comments
Download patch
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome/inspector_websocket.py ('k') | no next file » | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
diff --git a/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py b/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
index d270aa347f466e966523378e0a60afb5bd6e19df..d556febe29184d32ba5ace476e3272e38dcf2d40 100644
--- a/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
+++ b/tools/telemetry/telemetry/core/backends/chrome/tracing_backend.py
@@ -28,6 +28,10 @@ class TracingUnsupportedException(Exception):
pass
+class TracingTimeoutException(Exception):
+ pass
+
+
class CategoryFilter(object):
def __init__(self, filter_string):
self.excluded = set()
@@ -110,10 +114,11 @@ class TracingBackend(object):
self._category_filter = None
self._nesting = 0
self._tracing_data = []
+ self._is_tracing_running = False
@property
def is_tracing_running(self):
- return self._inspector_websocket.is_dispatching_async_notifications
+ return self._is_tracing_running
def StartTracing(self, custom_categories=None, timeout=10):
""" Starts tracing on the first nested call and returns True. Returns False
@@ -134,12 +139,10 @@ class TracingBackend(object):
if custom_categories:
req['params'] = {'categories': custom_categories}
self._inspector_websocket.SyncRequest(req, timeout)
- # Tracing.start will send asynchronous notifications containing trace
- # data, until Tracing.end is called.
- self._inspector_websocket.StartAsyncDispatchNotifications()
+ self._is_tracing_running = True
return True
- def StopTracing(self):
+ def StopTracing(self, timeout=30):
""" Stops tracing on the innermost (!) nested call, because we cannot get
results otherwise. Resets _tracing_data on the outermost nested call.
Returns the result of the trace, as TracingTimelineData object.
@@ -149,7 +152,19 @@ class TracingBackend(object):
if self.is_tracing_running:
req = {'method': 'Tracing.end'}
self._inspector_websocket.SendAndIgnoreResponse(req)
- self._inspector_websocket.StopAsyncDispatchNotifications()
+ # After Tracing.end, chrome browser will send asynchronous notifications
+ # containing trace data. This is until Tracing.tracingComplete is sent,
+ # which means there is no trace buffers pending flush.
+ try:
+ self._inspector_websocket.DispatchNotificationsUntilDone(timeout)
+ except \
+ inspector_websocket.DispatchNotificationsUntilDoneTimeoutException \
+ as err:
+ raise TracingTimeoutException(
+ 'Trace data was not fully received due to timeout after %s '
+ 'seconds. If the trace data is big, you may want to increase the '
+ 'time out amount.' % err.elapsed_time)
chrishenry 2014/07/11 18:27:59 nit: timeout
+ self._is_tracing_running = False
if self._nesting == 0:
self._category_filter = None
return self._GetTraceResultAndReset()
« no previous file with comments | « tools/telemetry/telemetry/core/backends/chrome/inspector_websocket.py ('k') | no next file » | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698