https://prefect.io logo
Title
k

Kelvin DeCosta

02/21/2023, 12:05 PM
Hey everyone! I have a question regarding
async
execution of tasks via
.map
. In the documentation for the
.map
function, it mentions that if the task that is being mapped is
async
, then the
.map
call must be awaited. However, I keep getting an error with the type checker stating that there are no overloads of
.map
that can be awaited. What should could be done to fix this?
1
z

Zanie

02/21/2023, 9:39 PM
k

Kelvin DeCosta

02/22/2023, 9:13 AM
I think that would solve it! Also, is there a major difference between these two approaches:
# using .submit
cors = [my_task.submit(param1=p, return_state=True) for p in params]
states = await asyncio.gather(*cors)

# using .map
states = await my_task.map(param1=params, return_state=True)
I think there's also a slight type checking issue with
return_state=True
and
async
tasks
z

Zanie

02/22/2023, 3:10 PM
There's not a major difference
Type checking doesn't work with the return state kwarg, Python type checking doesn't support extending your function signature with additional options
1
k

Kelvin DeCosta

02/22/2023, 4:43 PM
thank you for clarifying this!