| 389 | return arity_greater(header, n) |
| 390 | |
| 391 | def _call_task_errbacks(self, request, exc, traceback): |
| 392 | old_signature = [] |
| 393 | for errback in request.errbacks: |
| 394 | errback = self.app.signature(errback) |
| 395 | if not errback._app: |
| 396 | # Ensure all signatures have an application |
| 397 | errback._app = self.app |
| 398 | try: |
| 399 | if ( |
| 400 | # Celery tasks type created with the @task decorator have |
| 401 | # the __header__ property, but Celery task created from |
| 402 | # Task class do not have this property. |
| 403 | # That's why we have to check if this property exists |
| 404 | # before checking is it partial function. |
| 405 | hasattr(errback.type, '__header__') and |
| 406 | |
| 407 | # workaround to support tasks with bind=True executed as |
| 408 | # link errors. Otherwise, retries can't be used |
| 409 | not isinstance(errback.type.__header__, partial) and |
| 410 | # Classify the arguments still supplied by the failure, |
| 411 | # not arguments already stored on a mutable signature. |
| 412 | self._errback_arity_greater(errback, 1) |
| 413 | ): |
| 414 | try: |
| 415 | errback(request, exc, traceback) |
| 416 | except Exception: |
| 417 | logger.exception( |
| 418 | 'Errback %r raised an exception', |
| 419 | errback.name, |
| 420 | ) |
| 421 | else: |
| 422 | old_signature.append(errback) |
| 423 | except NotRegistered: |
| 424 | # Task may not be present in this worker. |
| 425 | # We simply send it forward for another worker to consume. |
| 426 | # If the task is not registered there, the worker will raise |
| 427 | # NotRegistered. |
| 428 | old_signature.append(errback) |
| 429 | |
| 430 | if old_signature: |
| 431 | # Previously errback was called as a task so we still |
| 432 | # need to do so if the errback only takes a single task_id arg. |
| 433 | task_id = request.id |
| 434 | root_id = request.root_id or task_id |
| 435 | g = group(old_signature, app=self.app) |
| 436 | if self.app.conf.task_always_eager or request.delivery_info.get('is_eager', False): |
| 437 | g.apply( |
| 438 | (task_id,), parent_id=task_id, root_id=root_id |
| 439 | ) |
| 440 | else: |
| 441 | g.apply_async( |
| 442 | (task_id,), parent_id=task_id, root_id=root_id |
| 443 | ) |
| 444 | |
| 445 | def mark_as_revoked(self, task_id, reason='', |
| 446 | request=None, store_result=True, state=states.REVOKED): |