def _call_task_errbacks(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) if ( # Celery tasks type created with the @task decorator have # the __header__ property, but Celery task created from # Task class do not have this property. # That's why we have to check if this property exists # before checking is it partial function. hasattr(errback.type, '__header__') and # workaround to support tasks with bind=True executed as # link errors. Otherwise retries can't be used not isinstance(errback.type.__header__, partial) and arity_greater(errback.type.__header__, 1) ): errback(request, exc, traceback) else: old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id group(old_signature, app=self.app).apply_async( (task_id,), parent_id=task_id, root_id=root_id )
def _call_task_errbacks(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) if ( # Celery tasks type created with the @task decorator have # the __header__ property, but Celery task created from # Task class do not have this property. # That's why we have to check if this property exists # before checking is it partial function. hasattr(errback.type, '__header__') and # workaround to support tasks with bind=True executed as # link errors. Otherwise retries can't be used not isinstance(errback.type.__header__, partial) and arity_greater(errback.type.__header__, 1)): errback(request, exc, traceback) else: old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id group(old_signature, app=self.app).apply_async((task_id, ), parent_id=task_id, root_id=root_id)
def _call_task_errbacks(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) if arity_greater(errback.type.__header__, 1): errback(request, exc, traceback) else: old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id group(old_signature, app=self.app).apply_async((task_id,), parent_id=task_id, root_id=root_id)
def _call_task_errbacks(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) if arity_greater(errback.type.__header__, 1): errback(request, exc, traceback) else: old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id group(old_signature, app=self.app).apply_async((task_id, ), parent_id=task_id, root_id=root_id)
def _call_task_errbacks(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) if not errback._app: # Ensure all signatures have an application errback._app = self.app try: if ( # Celery tasks type created with the @task decorator have # the __header__ property, but Celery task created from # Task class do not have this property. # That's why we have to check if this property exists # before checking is it partial function. hasattr(errback.type, '__header__') and # workaround to support tasks with bind=True executed as # link errors. Otherwise retries can't be used not isinstance(errback.type.__header__, partial) and arity_greater(errback.type.__header__, 1) ): errback(request, exc, traceback) else: old_signature.append(errback) except NotRegistered: # Task may not be present in this worker. # We simply send it forward for another worker to consume. # If the task is not registered there, the worker will raise # NotRegistered. old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id g = group(old_signature, app=self.app) if self.app.conf.task_always_eager or request.delivery_info.get('is_eager', False): g.apply( (task_id,), parent_id=task_id, root_id=root_id ) else: g.apply_async( (task_id,), parent_id=task_id, root_id=root_id )
def _call_task_errbacks_fix(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) # This check is necessary to solve a problem https://github.com/celery/celery/issues/4377 for celery 4.1.0 __header__ = getattr(errback.type, '__header__', None) if __header__ and arity_greater(__header__, 1): errback(request, exc, traceback) else: old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id group(old_signature, app=self.app).apply_async((task_id, ), parent_id=task_id, root_id=root_id)
def _call_task_errbacks(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) if ( # workaround to support tasks with bind=True executed as # link errors. Otherwise retries can't be used not isinstance(errback.type.__header__, partial) and arity_greater(errback.type.__header__, 1)): errback(request, exc, traceback) else: old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id group(old_signature, app=self.app).apply_async((task_id, ), parent_id=task_id, root_id=root_id)
def _call_task_errbacks(self, request, exc, traceback): old_signature = [] for errback in request.errbacks: errback = self.app.signature(errback) if ( # workaround to support tasks with bind=True executed as # link errors. Otherwise retries can't be used not isinstance(errback.type.__header__, partial) and arity_greater(errback.type.__header__, 1) ): errback(request, exc, traceback) else: old_signature.append(errback) if old_signature: # Previously errback was called as a task so we still # need to do so if the errback only takes a single task_id arg. task_id = request.id root_id = request.root_id or task_id group(old_signature, app=self.app).apply_async( (task_id,), parent_id=task_id, root_id=root_id )