Does anyone (<@U02GMEZU18B>!) knows how to handle ...
# ask-community
m
Does anyone (@Nate!) knows how to handle the migration of a HEAVILY async code to prefect? My impression so far is that you write normal sync code and prefect somehow can run it as async, so do I have to removed all async/await stuff from my code and rewrite it with that understanding? Does Prefect has a different concurrency model? How is it different from regular async/await (and while we are at it, multithreading too)?
n
hi @Mohamed Haggag - you're free to use normal async (or sync) python code with prefect (
asyncio
etc) but you can also make sync tasks run concurrently with `.submit` or `.map` if you want to prefect 2 did some magic to allow async code in sync contexts, which prefect 3 removes, see the following links for context: • https://github.com/PrefectHQ/prefect/issues/15008https://docs.prefect.io/v3/resources/upgrade-to-prefect-3#async-tasks-in-synchronous-flows
m
Thanks! Will check these two links. What situations where using async/await is more (or less) preferred compared with using sync +submit/map ?