|  | @@ -18,7 +18,6 @@ import threading
 | 
	
		
			
				|  |  |  from ... import states
 | 
	
		
			
				|  |  |  from ...datastructures import ExceptionInfo
 | 
	
		
			
				|  |  |  from ...exceptions import MaxRetriesExceededError, RetryTaskError
 | 
	
		
			
				|  |  | -from ...execute.trace import eager_trace_task
 | 
	
		
			
				|  |  |  from ...registry import tasks, _unpickle_task
 | 
	
		
			
				|  |  |  from ...result import EagerResult
 | 
	
		
			
				|  |  |  from ...utils import (fun_takes_kwargs, instantiate,
 | 
	
	
		
			
				|  | @@ -78,10 +77,6 @@ class TaskType(type):
 | 
	
		
			
				|  |  |          new = super(TaskType, cls).__new__
 | 
	
		
			
				|  |  |          task_module = attrs.get("__module__") or "__main__"
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        if "__call__" in attrs:
 | 
	
		
			
				|  |  | -            # see note about __call__ below.
 | 
	
		
			
				|  |  | -            attrs["__defines_call__"] = True
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          # - Abstract class: abstract attribute should not be inherited.
 | 
	
		
			
				|  |  |          if attrs.pop("abstract", None) or not attrs.get("autoregister", True):
 | 
	
		
			
				|  |  |              return new(cls, name, bases, attrs)
 | 
	
	
		
			
				|  | @@ -97,22 +92,6 @@ class TaskType(type):
 | 
	
		
			
				|  |  |              attrs["name"] = '.'.join([module_name, name])
 | 
	
		
			
				|  |  |              autoname = True
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | -        # - Automatically generate __call__.
 | 
	
		
			
				|  |  | -        # If this or none of its bases define __call__, we simply
 | 
	
		
			
				|  |  | -        # alias it to the ``run`` method, as
 | 
	
		
			
				|  |  | -        # this means we can skip a stacktrace frame :)
 | 
	
		
			
				|  |  | -        if not (attrs.get("__call__")
 | 
	
		
			
				|  |  | -                or any(getattr(b, "__defines_call__", False) for b in bases)):
 | 
	
		
			
				|  |  | -            try:
 | 
	
		
			
				|  |  | -                attrs["__call__"] = attrs["run"]
 | 
	
		
			
				|  |  | -            except KeyError:
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  | -                # the class does not yet define run,
 | 
	
		
			
				|  |  | -                # so we can't optimize this case.
 | 
	
		
			
				|  |  | -                def __call__(self, *args, **kwargs):
 | 
	
		
			
				|  |  | -                    return self.run(*args, **kwargs)
 | 
	
		
			
				|  |  | -                attrs["__call__"] = __call__
 | 
	
		
			
				|  |  | -
 | 
	
		
			
				|  |  |          # - Create and register class.
 | 
	
		
			
				|  |  |          # Because of the way import happens (recursively)
 | 
	
		
			
				|  |  |          # we may or may not be the first time the task tries to register
 | 
	
	
		
			
				|  | @@ -279,6 +258,9 @@ class BaseTask(object):
 | 
	
		
			
				|  |  |      def __reduce__(self):
 | 
	
		
			
				|  |  |          return (_unpickle_task, (self.name, ), None)
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  | +    def __call__(self, *args, **kwargs):
 | 
	
		
			
				|  |  | +        return self.run(*args, **kwargs)
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |      def run(self, *args, **kwargs):
 | 
	
		
			
				|  |  |          """The body of the task executed by workers."""
 | 
	
		
			
				|  |  |          raise NotImplementedError("Tasks must define the run method.")
 | 
	
	
		
			
				|  | @@ -582,6 +564,9 @@ class BaseTask(object):
 | 
	
		
			
				|  |  |          :rtype :class:`celery.result.EagerResult`:
 | 
	
		
			
				|  |  |  
 | 
	
		
			
				|  |  |          """
 | 
	
		
			
				|  |  | +        # trace imports BaseTask, so need to import inline.
 | 
	
		
			
				|  |  | +        from ...execute.trace import eager_trace_task
 | 
	
		
			
				|  |  | +
 | 
	
		
			
				|  |  |          args = args or []
 | 
	
		
			
				|  |  |          kwargs = kwargs or {}
 | 
	
		
			
				|  |  |          task_id = options.get("task_id") or uuid()
 |