airflow.providers.standard.triggers.temporal

Classes

DateTimeTrigger

Trigger based on a datetime.

TimeDeltaTrigger

Create DateTimeTriggers based on delays.

Module Contents

class airflow.providers.standard.triggers.temporal.DateTimeTrigger(moment=None, *, target_time=None, end_from_trigger=False)[source]

Bases: airflow.triggers.base.BaseTrigger

Trigger based on a datetime.

Pass either moment (a tz-aware datetime) or target_time (a string, possibly a Jinja template, or a datetime). With start_from_trigger, the operator lists target_time in its own template_fields and puts it in start_trigger_args.trigger_kwargs, so the triggerer renders it in place before run(); it is then parsed into moment on first use.

Parameters:
  • moment (datetime.datetime | None) – when to yield event

  • target_time (datetime.datetime | str | None) – raw (possibly templated) datetime string, an alternative to moment

  • end_from_trigger (bool) – whether the trigger should mark the task successful after time condition reached or resume the task after time condition reached.

target_time = None[source]
end_from_trigger = False[source]
property moment: pendulum.DateTime[source]
serialize()[source]

Return the information needed to reconstruct this Trigger.

Returns:

Tuple of (class path, keyword arguments needed to re-instantiate).

Return type:

tuple[str, dict[str, Any]]

async run()[source]

Loop until the relevant time is met.

We do have a two-phase delay to save some cycles, but sleeping is so cheap anyway that it’s pretty loose. We also don’t just sleep for “the number of seconds until the time” in case the system clock changes unexpectedly, or handles a DST change poorly.

class airflow.providers.standard.triggers.temporal.TimeDeltaTrigger(delta, *, end_from_trigger=False)[source]

Bases: DateTimeTrigger

Create DateTimeTriggers based on delays.

Subclass to create DateTimeTriggers based on time delays rather than exact moments.

While this is its own distinct class here, it will serialise to a DateTimeTrigger class, since they’re operationally the same.

Parameters:
  • delta (datetime.timedelta) – how long to wait

  • end_from_trigger (bool) – whether the trigger should mark the task successful after time condition reached or resume the task after time condition reached.

Was this entry helpful?