aio-libs / aio-libs/aiopg

cleanup aiopg.pool.Pool.cursor method

Ouverte
#264 2 commentaires 0 réactions 0 personnes assignées Voir sur GitHub
Langage dominant
Python
Étoiles
1.4k
Forks
170
Métriques de merge des PR
Aucune PR mergée en 30 j

Description

right now using this method is not async with nice, with the syntax:
```python
with (yield from pool.cursor()) as cur:
yield from cur.execute("SELECT 1")
```

Based on the usage of context managers in aiopg, it should instead behavior like aiopg.create_pool, to yield the following usage:
```python
async with pool.cursor() as cur:
yield from cur.execute("SELECT 1")
```

In order to accomplish this aiopg.pool.Pool.cursor should not be marked a coroutine, and the acquisition of the connection and cursor should not happen until `__aenter__` of _PoolCursorContextManager. With the current design probably the easiest way would be to pass a coroutine closure to _PoolCursorContextManager to return the conn and cur during `__aenter__`

Guide de contribution

Ouvrir le guide de contribution

Évaluation

Cette issue n'a pas encore été évaluée.

Recevez les nouvelles issues par e-mail

Un résumé court des issues GitHub adaptées aux débutants.