PythonSensor¶
PythonSensor
执行任意可调用对象,并等待其返回值变为 True。
提示
建议使用 @task.sensor
装饰器,而不是经典的 PythonSensor
来执行 Python 可调用对象以检查 True 条件。
# Using a sensor operator to wait for the upstream data to be ready.
@task.sensor(poke_interval=60, timeout=3600, mode="reschedule")
def wait_for_upstream() -> PokeReturnValue:
return PokeReturnValue(is_done=True, xcom_value="xcom_value")
t9 = PythonSensor(task_id="success_sensor_python", python_callable=success_callable)
t10 = PythonSensor(
task_id="failure_timeout_sensor_python", timeout=3, soft_fail=True, python_callable=failure_callable
)