|
@@ -1,15 +1,11 @@
|
|
|
from celery.task.base import Task
|
|
|
from celery.registry import tasks
|
|
|
+from inspect import getargspec
|
|
|
|
|
|
|
|
|
def task(**options):
|
|
|
"""Make a task out of any callable.
|
|
|
|
|
|
- :keyword name: Use a custom name, if not explicitly set
|
|
|
- the module and function name will be used, and
|
|
|
- the function name will be made into a standard class name,
|
|
|
- e.g. ``some_long_name`` becomes ``SomeLongName``.
|
|
|
-
|
|
|
:keyword autoregister: Automatically register the task in the
|
|
|
task registry.
|
|
|
|
|
@@ -43,11 +39,12 @@ def task(**options):
|
|
|
name = options.pop("name", None)
|
|
|
autoregister = options.pop("autoregister", True)
|
|
|
|
|
|
- cls_name = "".join(map(str.capitalize, fun.__name__.split("_")))
|
|
|
+ cls_name = fun.__name__
|
|
|
|
|
|
def run(self, *args, **kwargs):
|
|
|
return fun(*args, **kwargs)
|
|
|
run.__name__ = fun.__name__
|
|
|
+ run.argspec = getargspec(fun)
|
|
|
|
|
|
cls_dict = dict(options)
|
|
|
cls_dict["run"] = run
|
|
@@ -56,6 +53,6 @@ def task(**options):
|
|
|
task = type(cls_name, (Task, ), cls_dict)()
|
|
|
autoregister and tasks.register(task)
|
|
|
|
|
|
- return task()
|
|
|
+ return task
|
|
|
|
|
|
return _create_task_cls
|