MCPcopy
hub / github.com/celery/celery / on_timeout

Method on_timeout

celery/worker/request.py:529–548  ·  view source on GitHub ↗

Handler called if the task times out.

(self, soft, timeout)

Source from the content-addressed store, hash-verified

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."""

Calls 4

acknowledgeMethod · 0.95
warnFunction · 0.85
task_readyFunction · 0.85
mark_as_failureMethod · 0.80