This document describes the current stable version of Celery (5.6). For development docs, go here.

# `celery.utils.timer2`

Scheduler for Python functions.

Note

This is used for the thread-based worker only, not for amqp/redis/sqs/qpid where `kombu.asynchronous.timer` is used.

class celery.utils.timer2.Entry(fun, args=None, kwargs=None)

  Schedule Entry.

  args
  cancel()
  canceled
  property cancelled
  fun
  kwargs
  tref

celery.utils.timer2.Schedule

  alias of `Timer`

class celery.utils.timer2.Timer(schedule: Timer | None = None, on_error: Callable[[Exception], None] | None = None, on_tick: Callable[[float], None] | None = None, on_start: Callable[[Timer], None] | None = None, max_interval: float | None = None, **kwargs: Any)

  Timer thread.

  Note

  This is only used for transports not supporting AsyncIO.

  class Entry(fun, args=None, kwargs=None)

    Schedule Entry.

    args
    cancel()
    canceled
    property cancelled
    fun
    kwargs
    tref
  Schedule

    alias of `Timer`

  call_after(*args: Any, **kwargs: Any) → Entry
  call_at(*args: Any, **kwargs: Any) → Entry
  call_repeatedly(*args: Any, **kwargs: Any) → Entry
  cancel(tref: Entry) → None
  clear() → None
  empty() → bool
  ensure_started() → None
  enter(entry: Entry, eta: float, priority: int | None = None) → Entry
  enter_after(*args: Any, **kwargs: Any) → Entry
  exit_after(secs: float, priority: int = 10) → None
  next() → float | None
  on_tick: Callable[[float], None] | None = None
  property queue: list
  run() → None

    Method representing the thread’s activity.

    You may override this method in a subclass. The standard run() method invokes the callable object passed to the object’s constructor as the target argument, if any, with sequential and keyword arguments taken from the args and kwargs arguments, respectively.

  running: bool = False
  stop() → None

celery.utils.timer2.to_timestamp(d, default_timezone=zoneinfo.ZoneInfo(key='UTC'), time=<built-in function monotonic>)

  Convert datetime to timestamp.

  If d’ is already a timestamp, then that will be used.