Handler called if the task times out.
(self, soft, timeout)
| 527 | self.terminate(*self._terminate_on_ack) |
| 528 | |
| 529 | def on_timeout(self, soft, timeout): |
| 530 | """Handler called if the task times out.""" |
| 531 | if soft: |
| 532 | warn('Soft time limit (%ss) exceeded for %s[%s]', |
| 533 | timeout, self.name, self.id) |
| 534 | else: |
| 535 | task_ready(self) |
| 536 | # This is a special case where the task timeout handling is done during |
| 537 | # the cold shutdown process. |
| 538 | if not state.should_terminate: |
| 539 | error('Hard time limit (%ss) exceeded for %s[%s]', timeout, self.name, self.id) |
| 540 | exc = TimeLimitExceeded(timeout) |
| 541 | |
| 542 | self.task.backend.mark_as_failure( |
| 543 | self.id, exc, request=self._context, |
| 544 | store_result=self.store_errors, |
| 545 | ) |
| 546 | |
| 547 | if self.task.acks_late and self.task.acks_on_failure_or_timeout: |
| 548 | self.acknowledge() |
| 549 | |
| 550 | def on_success(self, failed__retval__runtime, **kwargs): |
| 551 | """Handler called if the task was successfully processed.""" |