Skip to content

Airflow-sensor-like Tasks #4156

Answered by cicdw
vsevolodbazhan asked this question in Q&A
Feb 23, 2021 · 1 comments · 5 replies
Discussion options

You must be logged in to vote

Hi @vsevolodbazhan - great question! You can recreate sensor-like behavior using the following pattern:

import pendulum
from prefect.engine.signals import RETRY


@task
def my_sensor(**kwargs):
    # check some state of the world
    if condition_not_met:
        raise RETRY("Condition not met, retrying in 5 seconds.", start_time=pendulum.now().add(seconds=5))

Replies: 1 comment 5 replies

Comment options

You must be logged in to vote
5 replies
@vsevolodbazhan
Comment options

@vsevolodbazhan
Comment options

@cicdw
Comment options

@cicdw
Comment options

@vsevolodbazhan
Comment options

Answer selected by vsevolodbazhan
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Category
Q&A
Labels
2 participants