|
@@ -9,9 +9,6 @@
|
|
|
from __future__ import absolute_import
|
|
|
from __future__ import with_statement
|
|
|
|
|
|
-import os
|
|
|
-import sys
|
|
|
-
|
|
|
from celery import current_app
|
|
|
from celery import states
|
|
|
from celery.__compat__ import class_property
|
|
@@ -19,7 +16,7 @@ from celery._state import get_current_worker_task, _task_stack
|
|
|
from celery.datastructures import ExceptionInfo
|
|
|
from celery.exceptions import MaxRetriesExceededError, RetryTaskError
|
|
|
from celery.result import EagerResult
|
|
|
-from celery.utils import fun_takes_kwargs, uuid, maybe_reraise
|
|
|
+from celery.utils import gen_task_name, fun_takes_kwargs, uuid, maybe_reraise
|
|
|
from celery.utils.functional import mattrgetter, maybe_list
|
|
|
from celery.utils.imports import instantiate
|
|
|
from celery.utils.mail import ErrorMail
|
|
@@ -34,12 +31,6 @@ extract_exec_options = mattrgetter(
|
|
|
'serializer', 'delivery_mode', 'compression',
|
|
|
)
|
|
|
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-MP_MAIN_FILE = os.environ.get('MP_MAIN_FILE') or None
|
|
|
-
|
|
|
|
|
|
class Context(object):
|
|
|
|
|
@@ -112,15 +103,9 @@ class TaskType(type):
|
|
|
app = attrs['_app'] = _app1 or _app2 or current_app
|
|
|
|
|
|
|
|
|
- autoname = False
|
|
|
- if not attrs.get('name'):
|
|
|
- try:
|
|
|
- module_name = sys.modules[task_module].__name__
|
|
|
- except KeyError:
|
|
|
-
|
|
|
- module_name = task_module
|
|
|
- attrs['name'] = '.'.join(filter(None, [module_name, name]))
|
|
|
- autoname = True
|
|
|
+ task_name = attrs.get('name')
|
|
|
+ if not task_name:
|
|
|
+ attrs['name'] = task_name = gen_task_name(app, name, task_module)
|
|
|
|
|
|
|
|
|
|
|
@@ -128,17 +113,6 @@ class TaskType(type):
|
|
|
|
|
|
|
|
|
tasks = app._tasks
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
-
|
|
|
- if MP_MAIN_FILE and sys.modules[task_module].__file__ == MP_MAIN_FILE:
|
|
|
-
|
|
|
- task_module = '__main__'
|
|
|
- if autoname and task_module == '__main__' and app.main:
|
|
|
- attrs['name'] = '.'.join([app.main, name])
|
|
|
-
|
|
|
- task_name = attrs['name']
|
|
|
if task_name not in tasks:
|
|
|
tasks.register(new(cls, name, bases, attrs))
|
|
|
instance = tasks[task_name]
|