|
@@ -1,7 +1,7 @@
|
|
|
"""celery.registry"""
|
|
|
from celery import discovery
|
|
|
from celery.utils import get_full_cls_name
|
|
|
-from celery.exceptions import NotRegistered, AlreadyRegistered
|
|
|
+from celery.exceptions import NotRegistered
|
|
|
from UserDict import UserDict
|
|
|
import inspect
|
|
|
|
|
@@ -9,7 +9,6 @@ import inspect
|
|
|
class TaskRegistry(UserDict):
|
|
|
"""Site registry for tasks."""
|
|
|
|
|
|
- AlreadyRegistered = AlreadyRegistered
|
|
|
NotRegistered = NotRegistered
|
|
|
|
|
|
def __init__(self):
|
|
@@ -21,25 +20,13 @@ class TaskRegistry(UserDict):
|
|
|
|
|
|
def register(self, task):
|
|
|
"""Register a task in the task registry.
|
|
|
-
|
|
|
- Task can either be a regular function, or a class inheriting
|
|
|
- from :class:`celery.task.Task`.
|
|
|
-
|
|
|
- :keyword name: By default the :attr:`Task.name` attribute on the
|
|
|
- task is used as the name of the task, but you can override it
|
|
|
- using this option.
|
|
|
-
|
|
|
- :raises AlreadyRegistered: if the task is already registered.
|
|
|
-
|
|
|
+
|
|
|
+ The task will be automatically instantiated if it's a class
|
|
|
+ not an instance.
|
|
|
"""
|
|
|
|
|
|
task = task() if inspect.isclass(task) else task
|
|
|
name = task.name
|
|
|
-
|
|
|
- if name in self.data:
|
|
|
- raise self.AlreadyRegistered(
|
|
|
- "Task with name %s is already registered." % name)
|
|
|
-
|
|
|
self.data[name] = task
|
|
|
|
|
|
def unregister(self, name):
|