Browse Source

celery.decorators.task: Return instance from registry

Ask Solem 14 years ago
parent
commit
5d91eaa6dd
1 changed files with 3 additions and 1 deletions
  1. 3 1
      celery/decorators.py

+ 3 - 1
celery/decorators.py

@@ -5,6 +5,7 @@ Decorators
 """
 from inspect import getargspec
 
+from celery import registry
 from celery.task.base import Task, PeriodicTask
 from celery.utils.functional import wraps
 
@@ -58,7 +59,8 @@ def task(*args, **options):
             cls_dict = dict(options, run=run,
                             __module__=fun.__module__,
                             __doc__=fun.__doc__)
-            return type(fun.__name__, (base, ), cls_dict)()
+            T = type(fun.__name__, (base, ), cls_dict)()
+            return registry.tasks[T.name] # global instance.
 
         return _create_task_cls