Skip to content

Instantly share code, notes, and snippets.

@anna-geller
Last active November 19, 2021 10:19
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save anna-geller/0dca1181d56e797f38390ad8850c54d7 to your computer and use it in GitHub Desktop.
Save anna-geller/0dca1181d56e797f38390ad8850c54d7 to your computer and use it in GitHub Desktop.
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