Last active
November 19, 2021 10:19
-
-
Save anna-geller/0dca1181d56e797f38390ad8850c54d7 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from prefect import task, Flow | |
from prefect.tasks.prefect import create_flow_run | |
import time | |
@task(log_stdout=True) | |
def hello_world(): | |
print("Sleeping...") | |
time.sleep(4) # to have enough time to kill it | |
return "hello world" | |
def never_ending_state_handler(obj, old_state, new_state): | |
if new_state.is_successful(): | |
create_flow_run.run(flow_name="never-ending-flow", project_name="community") | |
return new_state | |
with Flow("never-ending-flow", state_handlers=[never_ending_state_handler]) as flow: | |
hello_task = hello_world() |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment