https://prefect.io logo
Title
c

Constantino Schillebeeckx

03/10/2022, 3:29 PM
How can I run two tasks (one that is mapped, the other that is not) in parallel?
@task
def sleep_5():
    print(f'sleeping 5')
    time.sleep(5)
    print(f'done sleeping 5')


@task
def sleep_x(x):
    print(f'sleeping {x}')
    time.sleep(x)
    print(f'done sleeping {x}')


with DHFlow("foo") as flow:
    sleep_5()
    sleep_x.map([7, 8])
when I execute the above,
sleep_5
is run first; only after it finishes will
sleep_x
run.
k

Kevin Kho

03/10/2022, 3:29 PM
I don’t think you can. There is a limitation in Prefect 1 that only one mapped distinct mapped task can be run at a time right now.
c

Constantino Schillebeeckx

03/10/2022, 3:32 PM
cool - thanks for the confirmation