-
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
Add run_flow_in_subprocess
utility
#16802
Conversation
CodSpeed Performance ReportMerging #16802 will not alter performanceComparing Summary
|
25485cf
to
9239c3b
Compare
36ded36
to
577b457
Compare
run_flow_in_subprocess
utility
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
lgtm
flow: "Flow[..., Any]", | ||
flow_run: "FlowRun | None" = None, | ||
parameters: dict[str, Any] | None = None, | ||
wait_for: Iterable[PrefectFuture[R]] | None = None, |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sorry, i was late to review, but this shouldn't be R
should it?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Ah yeah you're right
This PR adds a
run_flow_in_subprocess
utility, which encapsulates the logic necessary to take an in-memoryFlow
object and run it in a separate process. This utility will be useful when used within theRunner
, which can hold onto in-memoryFlow
objects when started viaflow.server
and simplify code retrieval when executing flow runs for remotely stored flows.run_flow_in_subprocess
usescloudpickle
to serialize the provided flow, parameters, and other kwargs when delegating execution to a subprocess. Subprocesses are created via spawn rather than fork because the flow engine deadlocks when started in a forked process. I haven't yet discovered why it deadlocks in a forked process, but it'd be worthwhile to understand and potentially resolve that behavior.