Utility for registering a task-based class. Note: This is here for compatibility with old Celery 1.0 style task classes, you should not need to use this for new projects.
(self, task, **options)
| 629 | return task |
| 630 | |
| 631 | def register_task(self, task, **options): |
| 632 | """Utility for registering a task-based class. |
| 633 | |
| 634 | Note: |
| 635 | This is here for compatibility with old Celery 1.0 |
| 636 | style task classes, you should not need to use this for |
| 637 | new projects. |
| 638 | """ |
| 639 | task = inspect.isclass(task) and task() or task |
| 640 | if not task.name: |
| 641 | task_cls = type(task) |
| 642 | task.name = self.gen_task_name( |
| 643 | task_cls.__name__, task_cls.__module__) |
| 644 | add_autoretry_behaviour(task, **options) |
| 645 | self.tasks[task.name] = task |
| 646 | task._app = self |
| 647 | task.bind(self) |
| 648 | return task |
| 649 | |
| 650 | def gen_task_name(self, name, module): |
| 651 | return gen_task_name(self, name, module) |