summaryrefslogtreecommitdiff
path: root/gear/client.py
diff options
context:
space:
mode:
Diffstat (limited to 'gear/client.py')
-rw-r--r--gear/client.py19
1 files changed, 9 insertions, 10 deletions
diff --git a/gear/client.py b/gear/client.py
index cd21eeb8..b4abc8df 100644
--- a/gear/client.py
+++ b/gear/client.py
@@ -89,9 +89,9 @@ class SingleBuildController():
self._map_build_graph(self.artifact, update_state)
# TODO: move to RQ
self.build_started = True
- if requests_controller.lock_queue.locked():
+ with requests_controller.lock_queue:
+ requests_controller.lock_queue.notify()
print "DEBUG: queque release!"
- requests_controller.lock_queue.release()
def _map_build_graph(self, artifact, callback, components=[]):
"""Run callback on each artifact in the build graph and return result.
@@ -254,8 +254,7 @@ class RequestsController():
def __init__(self):
self.next_id = 1
self.new_request_lock = threading.Lock()
- self.lock_queue = threading.Lock()
- self.lock_queue.acquire()
+ self.lock_queue = threading.Condition()
self.build_requests = []
self.build_status_lock = threading.Lock()
@@ -272,7 +271,7 @@ class RequestsController():
self.build_requests.append(request_data)
def queue_if_possible(self):
- # TODO: check all of them in a loop?
+ print "DEBUG: Looking for jobs to queue"
for request in self.build_requests:
print request['id']
controller = request['controller']
@@ -293,8 +292,9 @@ class RequestsController():
for artifact in artifacts:
artifact.state = BUILT
print "TO %s: Artifact %s built" % (request['id'],artifact.name)
- if self.lock_queue.locked():
- self.lock_queue.release()
+
+ with self.lock_queue:
+ self.lock_queue.notify()
def mark_as_building(self, cache_key):
@@ -311,9 +311,8 @@ class RequestsController():
def loop(self):
while True:
- print "DEBUG: locking queue"
- self.lock_queue.acquire()
- print "DEBUG locked queue"
+ with self.lock_queue:
+ self.lock_queue.wait(20)
self.queue_if_possible()
request = {}