MagicStack / MagicStack/asyncpg
TempCluster() and pytest
Nessuno ha ancora preso questa issue.
- Lingua principale
- Python
- Stelle
- 8.1k
- Fork
- 468
- Metriche di merge delle PR
- Nessuna PR unita negli ultimi 30g
Descrizione
- asyncpg version: 0.23.0
- PostgreSQL version: N/A
- Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
the issue with a local PostgreSQL install?: N/A - Python version: 3.8.9 (but N/A)
- Platform: N/A
- Do you use pgbouncer?: N/A
- Did you install asyncpg with pip?: yes
- If you built asyncpg locally, which version of Cython did you use?:
- Can the issue be reproduced under both asyncio and
uvloop?:
This is issue which happens when using TempCluster() for testing as mentioned in https://github.com/MagicStack/asyncpg/issues/589.
Basically invoking cluster.start() causes an error when trying to use in environment that sets up own event loop (like pytest). Because .start() calls self._test_connection(timeout=wait) which creates and uses own event loop (https://github.com/MagicStack/asyncpg/blob/d08a9b8b9c2c68d469aeb9c4112d83c56c24f11c/asyncpg/cluster.py#L467).
This can be worked around by using nest_asyncio package, but it would be great if we could pass the event loop to the start() method so no hacking around that would be needed.
Guida per i contributori
Nessuna guida per i contributori indicizzata per questo repository
Come iniziare
- Leggi tutta la issue e poi la guida ai contributi del progetto.
- Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
- Fai un fork del repository e lavora su un branch.
- Apri una pull request che faccia riferimento al numero della issue.
Direzione di ricerca
Il problema segnalato si trova in asyncpg/cluster.py, nella parte relativa a TempCluster.start() e alla relativa chiamata a _test_connection(timeout=wait). Riproduci il percorso di avvio con pytest o in un altro ambiente con un proprio event loop, quindi determina come dovrebbe propagarsi lungo tale percorso l'argomento loop richiesto. Il lavoro è completato quando cluster.start() può usare l'event loop del chiamante senza richiedere nest_asyncio, con una coverage per lo scenario segnalato.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Valutazione
- Stack tecnologico
- postgresql, python
- Ambito
- databases, testing
- Tipo di issue
- Funzionalità
- Difficoltà
- 4/5
- Tempo stimato
- 3-5 giorni
- Stato di attività
- Ferma
- Chiarezza
- Abbastanza chiara
- Idoneità per principianti
- 35/100