diff options
author | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-03-30 21:55:19 +0000 |
---|---|---|
committer | Pedro Alvarez <pedro.alvarez@codethink.co.uk> | 2016-03-30 21:55:19 +0000 |
commit | 05899546f79d9604e1d6cd0ab718fdc670770579 (patch) | |
tree | aefb0d750c9dba67a81cdfcd3d82987cdd6908cb /gear/controller.py | |
parent | ea91a14e56efe070c977e9ff2877a23f3c498e92 (diff) | |
download | morph-05899546f79d9604e1d6cd0ab718fdc670770579.tar.gz |
Cancel now running jobs
Change-Id: I28bdb73cb59196fe35b0e891490ffc95acfeb1b5
Diffstat (limited to 'gear/controller.py')
-rw-r--r-- | gear/controller.py | 15 |
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" |