I have a bit of confusion about the way BaseSensorOperator
's parameters work: timeout
& poke_interval
.
Consider this usage of the sensor :
BaseSensorOperator(
soft_fail=True,
poke_interval = 4*60*60, # Poke every 4 hours
timeout = 12*60*60, # Timeout after 12 hours
)
The documentation mentions the timeout acts to set the task to 'fail' after it runs out. But I'm using a soft_fail=True
, I don't think it retains the same behavior, because I've found the task failed instead of skipping after I've used both parameters soft_fail
and timeout
.
So what does happen here?
- The sensor pokes every 4 hours, and at every poke, will wait for the duration of the timeout (12 hours)?
- Or does it poke every 4 hours, for a total of 3 pokes, then times out?
- Also, what happens with these parameters if I use the mode="reschedule"?
Here's the documentation of the BaseSensorOperator
class BaseSensorOperator(BaseOperator, SkipMixin):
"""
Sensor operators are derived from this class and inherit these attributes.
Sensor operators keep executing at a time interval and succeed when
a criteria is met and fail if and when they time out.
:param soft_fail: Set to true to mark the task as SKIPPED on failure
:type soft_fail: bool
:param poke_interval: Time in seconds that the job should wait in
between each tries
:type poke_interval: int
:param timeout: Time, in seconds before the task times out and fails.
:type timeout: int
:param mode: How the sensor operates.
Options are: ``{ poke | reschedule }``, default is ``poke``.
When set to ``poke`` the sensor is taking up a worker slot for its
whole execution time and sleeps between pokes. Use this mode if the
expected runtime of the sensor is short or if a short poke interval
is requried.
When set to ``reschedule`` the sensor task frees the worker slot when
the criteria is not yet met and it's rescheduled at a later time. Use
this mode if the expected time until the criteria is met is. The poke
inteval should be more than one minute to prevent too much load on
the scheduler.
:type mode: str
"""
mode=reschedule
parameter works seems indeed like the logical default behavior we want any sensor to have normally... e.g. If a dag runs 30 subdags, each responsible for the ETL of a data file, then 30 sensors poking and waiting seems like a really bad idea. – Waterspout