Recently I'm looking into python asyncio and coroutines, I've understood the event loop and I'm successfully using async implemented libraries with the syntax await/async using FASTAPI as a framework for building REST APIs.
Now, I need to use a library which has not been developed asynchronously, and which contains a lot of I/O bound functions (to binary connect to a custom server and do some proprietary logic).
I would like to make some function calls of this library async, but I'm not sure what should be the correct way to transform a generic function in a coroutine, and if it makes sense at all.
So far I'm just wrapping the function in this way:
import asyncio
async def my_function():
await asyncio.get_event_loop().run_in_executor(None, the_library_sync_function)
Is that the correct way to make a function awaitable? Are there any drawbacks? Am I getting it right?
Thank you