ThreadHey, i got a sync function that i want to call asyncronously in a loop
7 messages · –C Don't do it. Running a synchronous function in async context breaks your loop in a way that the other concurrent functions won't run until you're done. This is likely what you have experienced when trying to make it work. Run the code in a different thread, that puts it outside of the context of the asynchronous loop. Try asyncio.to_thread and asyncio.gather.A C asyncio.to_thread is the abstraction. The answer only changes if the synchronous function is developer-owned and can be converted to a native asynchronous function. Unless of course there's an option to just pick an asynchronous library (assuming the synchronous function comes from a library) to replace the synchronous function.G
G