summaryrefslogtreecommitdiff
path: root/buildstream
diff options
context:
space:
mode:
authorTristan Van Berkom <tristan.vanberkom@codethink.co.uk>2018-04-09 16:55:24 +0900
committerTristan Van Berkom <tristan.van.berkom@gmail.com>2018-04-09 10:25:36 +0000
commit62346702d28c0d5cf6c487ec250c6ee810904216 (patch)
treef97ad6d4317ae2bdab6dde9f4e3519bd3fcf4e23 /buildstream
parent26f7f0b86534d6acc72b8a416f944c49d2da49eb (diff)
downloadbuildstream-62346702d28c0d5cf6c487ec250c6ee810904216.tar.gz
element.py: Manage scheduled tracking state in Element
This removes the scheduled state of tracking from Sources, as this is really an element wide thing. To be consistent with assembly, now this comes with: o Element._schedule_tracking() o Element._tracking_done() o Element.__tracking_scheduled o Element.__tracking_done Updated the TrackQueue() to call Element._tracking_done() similarly to how we have BuildQueue() call Element._assemble_done().
Diffstat (limited to 'buildstream')
-rw-r--r--buildstream/_scheduler/trackqueue.py2
-rw-r--r--buildstream/element.py24
-rw-r--r--buildstream/source.py16
3 files changed, 21 insertions, 21 deletions
diff --git a/buildstream/_scheduler/trackqueue.py b/buildstream/_scheduler/trackqueue.py
index c3ee7cf7d..5832e4602 100644
--- a/buildstream/_scheduler/trackqueue.py
+++ b/buildstream/_scheduler/trackqueue.py
@@ -68,7 +68,7 @@ class TrackQueue(Queue):
source.warn("Failed to update project file",
detail="{}".format(e))
- element._update_state()
+ element._tracking_done()
# We'll appear as a skipped element if tracking resulted in no change
return changed
diff --git a/buildstream/element.py b/buildstream/element.py
index 0f68bf606..867937115 100644
--- a/buildstream/element.py
+++ b/buildstream/element.py
@@ -156,6 +156,8 @@ class Element(Plugin):
self.__remotely_strong_cached = None # Whether we have a remotely cached artifact
self.__assemble_scheduled = False # Element is scheduled to be assembled
self.__assemble_done = False # Element is assembled
+ self.__tracking_scheduled = False # Sources are scheduled to be tracked
+ self.__tracking_done = False # Sources have been tracked
self.__pull_failed = False # Whether pull was attempted but failed
self.__log_path = None # Path to dedicated log file or None
self.__splits = None
@@ -830,8 +832,18 @@ class Element(Plugin):
# succeeds.
#
def _schedule_tracking(self):
- for source in self.__sources:
- source._schedule_tracking()
+ self.__tracking_scheduled = True
+ self._update_state()
+
+ # _tracking_done():
+ #
+ # This is called in the main process after the element has been tracked
+ #
+ def _tracking_done(self):
+ assert self.__tracking_scheduled
+
+ self.__tracking_scheduled = False
+ self.__tracking_done = True
self._update_state()
@@ -852,7 +864,7 @@ class Element(Plugin):
# _assemble_done():
#
# This is called in the main process after the element has been assembled
- # in both the main process and in a subprocess.
+ # and in the a subprocess after assembly completes.
#
# This will result in updating the element state.
#
@@ -1611,6 +1623,10 @@ class Element(Plugin):
#
def __update_source_state(self):
+ # Cannot resolve source state until tracked
+ if self.__tracking_scheduled:
+ return
+
# Determine overall consistency of the element
consistency = Consistency.CACHED
for source in self.__sources:
@@ -1644,7 +1660,7 @@ class Element(Plugin):
self.__update_source_state()
if self._get_consistency() == Consistency.INCONSISTENT:
- # Tracking is still pending
+ # Tracking may still be pending
return
if any([not source._stable() for source in self.__sources]):
diff --git a/buildstream/source.py b/buildstream/source.py
index 9d5449fbc..286db5707 100644
--- a/buildstream/source.py
+++ b/buildstream/source.py
@@ -88,7 +88,6 @@ class Source(Plugin):
self.__element_index = meta.element_index # The index of the source in the owning element's source list
self.__directory = meta.directory # Staging relative directory
self.__consistency = Consistency.INCONSISTENT # Cached consistency state
- self.__tracking = False # Source is scheduled to be tracked
self.__assemble_scheduled = False # Source is scheduled to be assembled
self.__workspace = None # Directory of the currently active workspace
@@ -311,8 +310,6 @@ class Source(Plugin):
# This must be called whenever the state of a source may have changed.
#
def _update_state(self):
- if self.__tracking:
- return
if self.__consistency < Consistency.CACHED:
@@ -326,17 +323,6 @@ class Source(Plugin):
def _get_consistency(self):
return self.__consistency
- # Mark a source as scheduled to be tracked
- #
- # This is used across the pipeline in sessions where the
- # source in question are going to be tracked. This is important
- # as it will prevent depending elements from producing cache
- # keys until the source is RESOLVED and also prevent depending
- # elements from being assembled until the source is CACHED.
- #
- def _schedule_tracking(self):
- self.__tracking = True
-
# _schedule_assemble():
#
# This is called in the main process before the element is assembled
@@ -443,8 +429,6 @@ class Source(Plugin):
# the ref, regardless of whether the original has changed.
self.set_ref(ref, node)
- self.__tracking = False
-
return changed
# _load_ref():