How can I run two tasks (one that is mapped, the o...
# ask-community
c
How can I run two tasks (one that is mapped, the other that is not) in parallel?
Copy code
@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
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
cool - thanks for the confirmation