Is this still the best way to run subflows in para...
# ask-community
k
d
Yea
k
what if subflows have to be dynamically created as in a for-loop?
would it work just as well to do like so:
Copy code
parallel_subflows = []
for s in stuff:
   subflow = subflow_func(s)
   parallel_subflows.append(subflow_func())
await asyncio.gather(*parallel_subflows)
It's the same
k
Neither the Prefect example nor mine use a list comprehension
d
Ah yes but you can pass dynamic args and it'll work
k
thanks, testing it now!
n
in case you want your subflows to be a standalone deployment @kasteph, i'll leave this here
k
wow, lifesaver 🫶
🦜 1
@Nate could asyncio run the apply method of the deployment instead (assuming using
Deployment.build_from_flow
)? e.g.
Copy code
asyncio.run(get_total_pokemon_weight_deployment.apply())
n
it depends on whether the context you're calling from is async or sync. if you're in an sync context, you should just be able to call
get_total_pokemon_weight_deployment.apply()
- in async context you can just
await
it
shouldnt have to use
asyncio.run
i dont think
k
worked nicely, thanks 🙂
n
👍