misc.config import HOST class Signal(object): def __init__(self, name): self._sync = [] self._async = [] @celery.task(name=name) def _(*args): for func in self._async: func(*args) def send(self, *args): for func in self._sync: func(*args) if self._async: self.task(*args) def __call__(self, func): self._sync.append(func) return func def delay(self, func): self._async.append(func) return func