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

Unified Diff: recipe_engine/stream_logdog.py

Issue 2378903002: Annotation protobuf code can now dump final. (Closed)
Patch Set: Created 4 years, 3 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 | « recipe_engine/arguments_pb2.py ('k') | recipes.py » ('j') | no next file with comments »
Expand Comments ('e') | Collapse Comments ('c') | Show Comments Hide Comments ('s')
Index: recipe_engine/stream_logdog.py
diff --git a/recipe_engine/stream_logdog.py b/recipe_engine/stream_logdog.py
index f7835ecc0c6d2e9fad2a27b2c15d015807163134..4aec670aba8a0b858bd3bdb756d903e72436e742 100644
--- a/recipe_engine/stream_logdog.py
+++ b/recipe_engine/stream_logdog.py
@@ -268,7 +268,7 @@ class StreamEngine(stream.StreamEngine):
def __init__(self, client=None, streamserver_uri=None, name_base=None,
- ignore_triggers=False, environment=None):
+ dump_path=None, ignore_triggers=False, environment=None):
"""Initializes a new LogDog/Annotation StreamEngine.
Args:
@@ -281,6 +281,8 @@ class StreamEngine(stream.StreamEngine):
None, a StreamClient will be created through probing.
name_base (str or None): The default stream name prefix that will be added
to generated LogDog stream names. If None, no prefix will be applied.
+ dump_path (str or None): If provided, a filesystem path where the final
+ recipe annotation protobuf binary will be dumped.
ignore_triggers (bool): Triggers are not supported in LogDog annotation
streams. If True, attempts to trigger will be silently ignored. If
False, they will cause a NotImplementedError to be raised.
@@ -292,6 +294,7 @@ class StreamEngine(stream.StreamEngine):
self._client = client
self._streamserver_uri = streamserver_uri
self._name_base = _StreamName(name_base)
+ self._dump_path = dump_path
self._ignore_triggers = ignore_triggers
self._env = environment or _Environment.probe()
@@ -363,7 +366,7 @@ class StreamEngine(stream.StreamEngine):
self._check()
# Shut down our annotation monitor and close our annotation stream.
- self._annotation_monitor.flush_and_join()
+ last_step_data = self._annotation_monitor.flush_and_join()
self._annotation_stream.close()
# Clear our client and state. We are now closed.
@@ -371,6 +374,11 @@ class StreamEngine(stream.StreamEngine):
self._client = None
self._astate = None
+ # If requested, write out the last step data.
+ if self._dump_path and last_step_data:
+ with open(self._dump_path, 'wb') as fd:
nodir 2016/09/28 23:02:22 please swap these two lines, so in the worst case
dnj 2016/09/28 23:04:11 Done.
+ fd.write(last_step_data)
+
def _check(self):
if self._astate is None:
return
@@ -511,10 +519,14 @@ class _AnnotationMonitor(object):
def flush_and_join(self):
"""Flushes any remaining updates and blocks until the monitor is complete.
+
+ Returns (pb.Step): The final Step protobuf, or None if no step data was
+ sent.
"""
# Mark that we're finished and signal our event.
with self._lock:
self._flush_now_locked(datetime.datetime.now())
+ return self._last_flush_data
@property
def latest(self):
« no previous file with comments | « recipe_engine/arguments_pb2.py ('k') | recipes.py » ('j') | no next file with comments »

Powered by Google App Engine
This is Rietveld 408576698