Hi everyone, We've been running into a problem whe...
# ask-community
g
Hi everyone, We've been running into a problem where each time we call multiple subflows with the
asyncio.gather
command, the first subflow executes correctly, though all of the other subflows will error. I believe the problem is compatibility with the
marvin
library. there seems to be a problem with the
async_utils
. The error message I see consistently is:
Copy code
Encountered exception during execution:
Traceback (most recent call last):
  File "/usr/local/lib/python3.10/site-packages/marvin/utilities/async_utils.py", line 61, in run_sync
    loop = asyncio.get_running_loop()
RuntimeError: no running event loop
Versions: marvin = "1.5.5" prefect = "2.14.3" Has anyone else in the community encountered this problem?
a
👋 @Gabe Villasana I've got 👀 on this. Do you have a quick path to reproduce on your end, otherwise can see if I can get something to witness it
g
Hey @Alexander Azzam, I'm deploying 2 flows using the
serve
method when my workers startup. I invoke flow
A
via the
run_deployment
command. Flow
A
calls subflow
B
via
await asyncio.gather
. Inside subflow
B
, I have a number of tasks which are wrappers around marvin functions. I'm using the
ConcurrentTaskRunner
. Happy to share code details over DMs 🙂
a
gotcha gotcha, that might be enough for me to reproduce but code always helpful - feel free to 👋 in DMs!
✉️ 1
@Taylor Curran does this error seem familiar to you (pretend it has nothing to do with Marvin)
g
If it's helpful: We just had a user kick off a data pipeline which resulted in 5 subflow invocations. 2 succeeded, 3 failed...
t
I have not seen that error, but if it is helpful, here is a repo with examples of different subflow patterns. Asyncio gather can be used to have non blocking subflows (or sub-deployments). https://github.com/taylor-curran/prefect-patterns/blob/main/flows/composite_flow_patterns/asyncio_gather_sub_deployments.py Also though, task wrapped sub-deployments can also allow you to achieve concurrent subflow execution: https://github.com/taylor-curran/prefect-patterns/blob/main/flows/composite_flow_patterns/task_wrapped_deployments.py
g
Thanks for sharing this Taylor! Going to dive in today 🙂
Hey @Taylor Curran, I'm running into an issue where my subflow is failing but my parent flow remains in the
Running
state. I was using the
asyncio.gather
to call the subflows via
run_deployment
similar to what you referenced in the first link. Is there a way I can check based on the results of the asyncio.gather call wehther my subflows failed? If any of them failed, I want the parent flow to fail as well
t
A failing subflow should affect the parent issues have been resolved like this to ensure the state of the parent is coupled with the sate of the child
but if it is an endlessly running flow that also sounds like a problem
a lot of this can differ depending on your execution env — for example, in the issue, subdeployments are executed in k8s
g
ye this takes place in k8s
both the main deployment and the subdeployments