Skip to content

Refactor connection/atomic/transaction context handling #5

@kszucs

Description

@kszucs

Due to the use of connection pool by default, the async with self.pool.acquire() idiom is required in most of the database methods. The async with hell gets complicated in the case of atomic operations. The with db.atomic() idiom requires the connection to be shipped downward resulting a deeply nested async context manager, which should look like a single one (from the API perspective). The original peewee implementation uses deque and heap structures to handle the nesting within a single thread.

The most painful parts are here:

I could use a more asyncio experienced point of view here :)
Could someone give me a hand / guidance?

cc @ajdavis @jettify

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions