Stop all tasks on shutdown
This stops all of the working jobs when turbo-hipster is closing down
Change-Id: Ic160f75bd8222b233f81d269e4c035f95be11e47
diff --git a/turbo_hipster/worker_manager.py b/turbo_hipster/worker_manager.py
index d011a03..0dcdaaf 100644
--- a/turbo_hipster/worker_manager.py
+++ b/turbo_hipster/worker_manager.py
@@ -79,7 +79,7 @@
""" Handle the requested job """
try:
job_arguments = json.loads(job.arguments.decode('utf-8'))
- self.tasks[job_arguments['name']].stop_worker(
+ self.tasks[job_arguments['name']].stop_working(
job_arguments['number'])
job.sendWorkComplete()
except Exception as e:
@@ -128,6 +128,8 @@
def stop(self):
self._stop.set()
+ for task in self.functions.values():
+ task.stop_working()
# Unblock gearman
self.log.debug("Telling gearman to stop waiting for jobs")
self.gearman_worker.shutdown()