-
Notifications
You must be signed in to change notification settings - Fork 1.7k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Workflow hangs when tasks or sub-flows using ProcessPool with start method fork
#9229
Comments
fork
fork
This issue is stale because it has been open 30 days with no activity. To keep this issue open remove stale label or comment. |
I have experienced this as well.
from prefect.something import offending_function
def call_offending_function_sync():
async def wrapper():
await offending_function()
asyncio.run(wrapper()) It's rather surprising to me that the sync compatibility decorator doesn't take a similar approach with |
@zanieb here's the shortest example I've been able to come up with: import multiprocessing as mp
from prefect_aws import S3Bucket
S3Bucket.load("bucket-name")
if __name__ == "__main__":
proc = mp.get_context("fork").Process(target=lambda: None, daemon=True)
proc.start()
proc.join() |
@zanieb if you comment out this line it does not hang: prefect/src/prefect/blocks/core.py Line 639 in c924f42
|
My earlier statement about this being related to import asyncio
import multiprocessing as mp
from prefect_aws import S3Bucket
async def func():
await S3Bucket.load("global-storage")
asyncio.run(func())
if __name__ == "__main__":
proc = mp.get_context("fork").Process(target=lambda: None, daemon=True)
proc.start()
proc.join() |
Going one layer deeper, removing usage of this lock also prevents the hang:
Seems related to the problem in this article - the lock is likely being copied in an acquired state. The subprocess thus, can never acquire the lock. |
The solution seem to just not use forked subprocesses. According to the article:
|
First check
Bug summary
When calling a user defined task or sub-flow from entry point flow, if it invokes a Process Pool, Prefect might hangs forever.
Reproduction
Error
Versions
Additional context
No response
The text was updated successfully, but these errors were encountered: