Jack P
11/15/2023, 4:22 PMprefect.utilities.asyncutils.sync_compatible
being used?Marvin
11/15/2023, 4:22 PMprefect.utilities.asyncutils.sync_compatible
being used. However, I found some information about it in the Prefect release notes. It seems to be part of the improvements made to the Prefect engine to support mixed asynchronous and synchronous code.
Here is the excerpt from the release notes:
"Supporting mixed asynchronous and synchronous code is complicated, but important. When designing Prefect 2, we wanted to account for the future growth of asynchronous Python and the many user requests for asynchronous task support. Most of this complexity is buried in the Prefect engine, which manages execution of your flows and tasks. With this release, we've made some dramatic improvements to the engine, closing some long-standing bugs and ensuring that it isn't a point of failure when running your flows.
The behavioral changes include:
- All orchestration of flows and tasks happens in a dedicated worker thread
- Synchronous flows are run on the main thread instead of worker threads"
You can find more details in the Prefect Release Notes.
For a specific example, I would recommend checking the Prefect documentation or reaching out to the Prefect community.Nate
11/15/2023, 4:24 PMIn [6]: @sync_compatible
...: async def some_async_fn():
...: print("foo")
...:
In [7]: await some_async_fn()
foo
In [8]: some_async_fn()
foo
Jack P
11/15/2023, 4:24 PMNate
11/15/2023, 4:24 PMNate
11/15/2023, 4:25 PMJack P
11/15/2023, 4:25 PMNate
11/15/2023, 4:26 PM