airflow.providers.standard.triggers.temporal

Module Contents

Classes

DateTimeTrigger

Trigger based on a datetime.

TimeDeltaTrigger

Create DateTimeTriggers based on delays.

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

Bases: airflow.triggers.base.BaseTrigger

Trigger based on a datetime.

A trigger that fires exactly once, at the given datetime, give or take a few seconds.

The provided datetime MUST be in UTC.

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

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

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?