Преглед на файлове

TaskType: Only use app.main if task.name is not explicitly set

Conflicts:

	celery/task/base.py
Ask Solem преди 14 години
родител
ревизия
fa7b012261
променени са 1 файла, в които са добавени 4 реда и са изтрити 2 реда
  1. 4 2
      celery/task/base.py

+ 4 - 2
celery/task/base.py

@@ -81,13 +81,15 @@ class TaskType(type):
             return new(cls, name, bases, attrs)
 
         # Automatically generate missing/empty name.
+        autoname = False
         if not attrs.get("name"):
             try:
                 module_name = sys.modules[task_module].__name__
             except KeyError:
                 # Fix for manage.py shell_plus (Issue #366).
                 module_name = task_module
-            attrs["name"] = '.'.join([task_module, name])
+            attrs["name"] = '.'.join([module_name, name])
+            autoname = True
 
         # Because of the way import happens (recursively)
         # we may or may not be the first time the task tries to register
@@ -96,7 +98,7 @@ class TaskType(type):
         task_name = attrs["name"]
         if task_name not in tasks:
             task_cls = new(cls, name, bases, attrs)
-            if task_module == "__main__" and task_cls.app.main:
+            if autoname and task_module == "__main__" and task_cls.app.main:
                 task_name = task_cls.name = '.'.join([task_cls.app.main, name])
             tasks.register(task_cls)
         task = tasks[task_name].__class__