YD
08/11/2021, 5:17 PMfrom datetime import timedelta
from prefect import task, Flow
from prefect.schedules import CronSchedule
from time import sleep
@task(max_retries=1, retry_delay=timedelta(minutes=10), timeout=2000)
def tast_1():
sleep(10)
print('Do task 1')
return True
@task(max_retries=1, retry_delay=timedelta(minutes=10), timeout=2000)
def tast_2():
sleep(10)
print('Do task 2')
return True
def main():
schedule = CronSchedule("0 15 * * *")
with Flow("parallel tasks", schedule=schedule) as flow:
r1 = tast_1()
r2 = tast_2()
flow.register(project_name="parallel tasks")
if __name__ == "__main__":
main()
Kyle McChesney
08/11/2021, 5:22 PMfrom prefect.executors import LocalDaskExecutor
...
with Flow("parallel tasks", schedule=schedule, executor=LocalDaskExecutor()) as flow:
YD
08/11/2021, 5:24 PMKevin Kho