Hey everyone! I have a question regarding `async`...
# best-practices
k
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
k
I think that would solve it! Also, is there a major difference between these two approaches:
Copy code
# 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
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
thank you for clarifying this!