diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-03-23 21:14:58 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-03-27 11:53:03 +0000 |
commit | 1cd15aa2e2d754b7c33b36c84b0426e1e8cbc098 (patch) | |
tree | 81d212654bb57971ba233bbf5eec04cbc1fa2959 /gear/client.py | |
parent | 168dd5f64a2251997f5fbab1c460c12ff557e0ed (diff) | |
download | morph-1cd15aa2e2d754b7c33b36c84b0426e1e8cbc098.tar.gz |
Check building components before cache
Change-Id: I563eccf779708afdf597147f8e88ce0351a400dc
Diffstat (limited to 'gear/client.py')
-rw-r--r-- | gear/client.py | 28 |
1 files changed, 23 insertions, 5 deletions
diff --git a/gear/client.py b/gear/client.py index b4abc8df..dea67a0d 100644 --- a/gear/client.py +++ b/gear/client.py @@ -34,6 +34,7 @@ class SingleBuildController(): self.cache_client.waitForServer() self.artifact = None self.build_started = False + self.build_initiated = False def start_build(self, request): job = gear.Job("build-graph", request) @@ -59,16 +60,28 @@ class SingleBuildController(): print "Setting them as unbuilt" self._map_build_graph(self.artifact, set_initial_state) print "Setting them as unbuilt done" - self._check_cache_state(self.artifact) + self.build_initiated = True + self._check_cache_state() - def _check_cache_state(self, artifact): + def _check_cache_state(self): print "DEBUG: checking cache..." + + # Check first building artifacts + def mark_building_artifacts(artifact): + if (artifact.state == UNBUILT and artifact.cache_key + in requests_controller.building_list): + artifact.state = BUILDING + with requests_controller.build_status_lock: + self._map_build_graph(self.artifact, mark_building_artifacts) + + artifact_names = [] def collect_unbuilt_artifacts(artifact): if artifact.state == UNBUILT: artifact_names.append(artifact.basename()) - self._map_build_graph(artifact, collect_unbuilt_artifacts) + with requests_controller.build_status_lock: + self._map_build_graph(self.artifact, collect_unbuilt_artifacts) job = gear.Job("cache-request", json.dumps(artifact_names)) self.cache_client.submitJob(job) @@ -252,6 +265,7 @@ class BuilderClient(gear.Client): class RequestsController(): def __init__(self): + self.building_list = [] self.next_id = 1 self.new_request_lock = threading.Lock() self.lock_queue = threading.Condition() @@ -285,9 +299,11 @@ class RequestsController(): def mark_as_built(self, cache_key): with self.build_status_lock: + self.building_list.remove(cache_key) + print self.building_list for request in self.build_requests: controller = request['controller'] - if controller.artifact != None and controller.build_started == True: + if controller.artifact != None and controller.build_initiated == True: artifacts = request['controller']._find_artifacts(cache_key) for artifact in artifacts: artifact.state = BUILT @@ -299,9 +315,11 @@ class RequestsController(): def mark_as_building(self, cache_key): with self.build_status_lock: + self.building_list.append(cache_key) + print self.building_list for request in self.build_requests: controller = request['controller'] - if controller.artifact != None and controller.build_started == True: + if controller.artifact != None and controller.build_initiated == True: artifacts = request['controller']._find_artifacts(cache_key) for artifact in artifacts: artifact.state = BUILDING |