<@ULVA73B9P>, can you please show me example of `p...
# ask-marvin
j
@Marvin, can you please show me example of
prefect.utilities.asyncutils.sync_compatible
being used?
m
I'm sorry, but I couldn't find a specific example of
prefect.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.
👍 1
n
Copy code
In [6]: @sync_compatible
   ...: async def some_async_fn():
   ...:     print("foo")
   ...:

In [7]: await some_async_fn()
foo

In [8]: some_async_fn()
foo
j
legend ty
n
basically, you put it on an async fn to make it callable as a sync fn in a sync context, otherwise it works like an async fn
ipython is actually kind of a weird place to demo bc the implicit event loop but whatever
j
no this works, I did exactly what you listed and my silly function is working, thank u 🫡
n
catjam
typingcat 1