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/lib/models.py b/turbo_hipster/lib/models.py
index d445379..be3f1d9 100644
--- a/turbo_hipster/lib/models.py
+++ b/turbo_hipster/lib/models.py
@@ -68,11 +68,11 @@
if not self.cancelled:
self.job.sendWorkException(str(e).encode('utf-8'))
- def stop_worker(self, number):
- # Check the number is for this job instance
+ def stop_working(self, number=None):
+ # Check the number is for this job instance (None will cancel all)
# (makes it possible to run multiple workers with this task
# on this server)
- if number == self.job.unique:
+ if number is None or number == self.job.unique:
self.log.debug("We've been asked to stop by our gearman manager")
self.cancelled = True
# TODO: Work out how to kill current step