summaryrefslogtreecommitdiff
path: root/gear/controller.py
diff options
context:
space:
mode:
Diffstat (limited to 'gear/controller.py')
-rw-r--r--gear/controller.py15
1 files changed, 15 insertions, 0 deletions
diff --git a/gear/controller.py b/gear/controller.py
index 83616d15..56022f08 100644
--- a/gear/controller.py
+++ b/gear/controller.py
@@ -198,6 +198,16 @@ class SingleBuildController():
self.requests_controller.mark_as_built(cache_key)
+class CancelationClient(gear.Client):
+ def __init__(self):
+ super(CancelationClient, self).__init__()
+
+ def handleWorkComplete(self, packet):
+ job = super(CancelationClient, self).handleWorkComplete(packet)
+ print "Cancelation workcomplete"
+ return job
+
+
class CacheRequestClient(gear.Client):
def __init__(self, controller):
super(CacheRequestClient, self).__init__()
@@ -280,6 +290,9 @@ class RequestsController(threading.Thread):
self.build_requests = []
self.build_status_lock = threading.Lock()
self.stopped = False
+ self.cancel_client = CancelationClient()
+ self.cancel_client.addServer('localhost')
+ self.cancel_client.waitForServer()
def add_request(self, request, job=None):
json_request = json.dumps(request)
@@ -376,6 +389,8 @@ class RequestsController(threading.Thread):
for cache_key in to_remove:
del self.building_dict[cache_key]
del self.jobs_dict[cache_key]
+ job = gear.Job("cancel-%s" % cache_key, cache_key)
+ self.cancel_client.submitJob(job)
print "Finished cancelling"