<#158 Nesting Asyncio> Pull request opened by <kum...
# flyte-github
a
#158 Nesting Asyncio Pull request opened by kumare3 If one wants to work with legacy code, where the codebase is sync, but uses libraries that have async loop captured in them, then it is recommended to use
nest_asyncio
library to nest async code into sync code import asyncio import nest_asyncio import flyte env = flyte.TaskEnvironment( "asyncclient_sync", image=flyte.Image.from_debian_base().with_pip_packages("aiohttp", "nest_asyncio"), ) nest_asyncio.apply() async def async_in_sync() -> str: await asyncio.sleep(1) return "done" @env.task def call_async() -> str: return asyncio.run(async_in_sync()) flyteorg/flyte-sdk