Either it doesn't need to be async, or the db io needs to be moved into a worker thread. E.g., use asyncio.to_thread(). A standard way of doing it is to rename this function into _store_message(), and then make an async wrapper like:
async def store_message(...) -> str:
return await asyncio.to_thread(_store_message, ...)
This way you have proper async io without blocking the main loop (which is deadly).
Originally posted by @pavel-kirienko in #40 (comment)
Either it doesn't need to be async, or the db io needs to be moved into a worker thread. E.g., use
asyncio.to_thread(). A standard way of doing it is to rename this function into_store_message(), and then make an async wrapper like:This way you have proper async io without blocking the main loop (which is deadly).
Originally posted by @pavel-kirienko in #40 (comment)