|
@@ -2,15 +2,22 @@ from celery.worker.revoke import revoked
|
|
|
from celery.registry import tasks
|
|
|
|
|
|
|
|
|
+def expose(fun):
|
|
|
+ fun.exposed = True
|
|
|
+ return fun
|
|
|
+
|
|
|
+
|
|
|
class Control(object):
|
|
|
|
|
|
def __init__(self, logger):
|
|
|
self.logger = logger
|
|
|
|
|
|
+ @expose
|
|
|
def revoke(self, task_id, **kwargs):
|
|
|
revoked.add(task_id)
|
|
|
self.logger.warn("Task %s revoked." % task_id)
|
|
|
|
|
|
+ @expose
|
|
|
def rate_limit(self, task_name, rate_limit):
|
|
|
try:
|
|
|
tasks[task_name].rate_limit = rate_limit
|
|
@@ -33,12 +40,12 @@ class ControlDispatch(object):
|
|
|
self.panel = self.panel_cls(self.logger)
|
|
|
|
|
|
def dispatch(self, command, kwargs):
|
|
|
+ control = None
|
|
|
try:
|
|
|
control = getattr(self.panel, command)
|
|
|
except AttributeError:
|
|
|
+ pass
|
|
|
+ if control is None or not control.exposed:
|
|
|
self.logger.error("No such control command: %s" % command)
|
|
|
else:
|
|
|
return control(**kwargs)
|
|
|
-
|
|
|
-
|
|
|
-
|