https://prefect.io logo
v

Vadym Dytyniak

11/15/2022, 8:53 AM
Hi. How to call sync task in async flow?(Prefect 2)
1
m

max

11/15/2022, 10:35 AM
Hey! There are should be no errors. Just try running it like you normally do.
v

Vadym Dytyniak

11/15/2022, 10:59 AM
It hangs, I found a workaround to make task async and now I can run it in both: sync and async flows.
👍 1
j

Jeff Hale

11/15/2022, 12:50 PM
Gals you got it working, Max, but it should work right off the bat. Can you share a MRE?
m

max

11/15/2022, 12:54 PM
what is MRE?
v

Vadym Dytyniak

11/15/2022, 12:58 PM
Copy code
@task()
def sync_task():
    get_run_logger().log('I am sync task')


@flow()
async def sample() -> None:
    sync_task()


if __name__ == '__main__':
    asyncio.run(sample())
🙌 1
n

Nate

11/15/2022, 3:45 PM
hey @max - MRE is just an acronym for Minimum Reproducible Example, so a little code snippet that captures a described issue and only contains code directly related to that issue
👍 1
m

max

11/15/2022, 3:46 PM
@Nate 😄 thanks!
👍 1
3 Views