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
)