-
Notifications
You must be signed in to change notification settings - Fork 6
Open
Labels
Description
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:
- https://github.com/kszucs/aiopeewee/blob/master/aiopeewee/database.py#L19 (i want to get rid of this abstraction
- https://github.com/kszucs/aiopeewee/blob/master/aiopeewee/context.py#L72 (currently this is a nightmare)
- https://github.com/kszucs/aiopeewee/blob/master/aiopeewee/database.py#L189 (mixture of coroutine, context manager, repeated us of
async with self.get_conn()
)
I could use a more asyncio experienced point of view here :)
Could someone give me a hand / guidance?