Skip to content

Make db operation async #44

Description

@songmeo

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)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions