Created
June 11, 2014 07:45
-
-
Save MaikuMori/268b957243d589018bc0 to your computer and use it in GitHub Desktop.
CeleryTaskProxy
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class CeleryTaskProxy(object): | |
""" | |
Method proxy to execute namespaced Celery tasks via send_task. | |
""" | |
def __init__(self, celery, namespace): | |
self._celery = celery | |
self._namespace = namespace | |
def __getattr__(self, attr): | |
def runner(*args, **kwargs): | |
task_name = "{}.{}".format(self._namespace, attr) | |
return self._celery.send_task(task_name, args, kwargs) | |
return runner |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment