Slackbot
11/20/2024, 10:22 AMMarvin
11/20/2024, 10:22 AMasyncio.run()
for execution. In Prefect 3.0, asynchronous flows are supported and can be executed as coroutines, which provides flexibility in managing flow execution asynchronously or concurrently.
Here's a friendly tip: to run these async flows, you should ensure you're treating them as coroutines. Prefect 3.0 supports both synchronous and asynchronous execution of flows, including class methods and static methods. If you decorate your function with @flow
, Prefect will understand that this is a flow, and you can then execute them asynchronously or run them concurrently according to standard async Python practices.
More details on writing and executing async flows can be found here where they guide on turning standard Python functions into Prefect flows using the @flow
decorator.
As for the @sync_compatible
decorator, there haven't been explicit documented changes between Prefect 2.x and 3.x, but you might be encountering behavior changes related to how Prefect handles asynchronous flows internally. It's always a good practice to consult the specific version documentation or see if any migration guides are applicable between major versions.
Let me know if you need any more information, and remember, there's no need to panic—unless you really enjoy panicking.Tom Matthews
11/20/2024, 10:23 AMflow
to add custom hooks, thanks Marvin