Application Flow Stuck Unless Connection is Explicitly Closed
Nessuno ha ancora preso questa issue.
Valutazione
- Difficoltà
- 3/5
- Tempo stimato
- 1-2 giorni
- Idoneità per principianti
- 25/100
Direzione di ricerca
Inizia con l’esempio asyncpg 0.30.0 fornito e riproducilo su Python 3.11, PostgreSQL 16 e Windows, verificando innanzitutto se il problema si verifica con un’installazione locale di PostgreSQL. Analizza il comportamento del context manager asincrono intorno a self.get_connection() e confrontalo con il caso con conn.close() esplicito; il lavoro è completo quando il flusso termina senza richiedere quella chiusura esplicita.
Scritto dal modello di indicizzazione a partire dal testo della issue.
Descrizione
- asyncpg version: 0.30.0
- PostgreSQL version: 16
- Do you use a PostgreSQL SaaS? If so, which?: Yes, I am using NeonDB
- Can you reproduce the issue with a local PostgreSQL install?: Didn't attempt it.
- Python version: 3.11.0
- Platform: Windows
- Do you use pgbouncer?: No
- Did you install asyncpg with pip?: Yes
- If you built asyncpg locally, which version of Cython did you use?: [Your Cython version if applicable]
- Can the issue be reproduced under both asyncio and
uvloop?: [Yes/No] I did not try uvloop
I'm encountering an issue where the flow of my application gets stuck unless the database connection is explicitly closed after a query, even though it should be managed automatically by the context manager.
Code Example:
async def read_record(self, request_details: dict):
"""
Retrieve records based on conditions and request_type.
Args:
request_details (dict): The conditions including request_type.
Returns:
list: The records that match the conditions.
"""
table = self.get_table_name(request_details['request_type'])
conditions = {key: request_details[key] for key in request_details if key != 'request_type'}
condition_str = " AND ".join(f"{key} = ${i+1}" for i, key in enumerate(conditions.keys()))
query = f"SELECT * FROM {table} WHERE {condition_str};"
async with self.get_connection() as conn:
conn.add_log_listener(lambda connection, message: logger.info("PostgreSQL log message: %s", message))
result = await conn.fetch(query, *conditions.values())
logger.info("Fetched records: %s", result)
# await conn.close() # get's stuck without this line
return result
- Lingua principale
- Python
- Stelle
- 8.1k
- Fork
- 469
- Merge medio
- 4h 42m
- PR unite (30g)
- 6
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.
Altre issue di MagicStack/asyncpg
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 78/100
MagicStack/asyncpg#1357 ·
-
tests fail in 2032 Aperta
Difficoltà 2/5 1-3 ore Idoneità per principianti 65/100
MagicStack/asyncpg#997 ·
-
Connection.close(timeout=) waits forever on a pending cancel when the server never acknowledges it Aperta
Difficoltà 4/5 3-5 giorni Idoneità per principianti 68/100
MagicStack/asyncpg#1356 ·
-
Difficoltà 4/5 3-5 giorni Idoneità per principianti 48/100
MagicStack/asyncpg#1354 ·
-
Difficoltà 3/5 1-2 giorni Idoneità per principianti 72/100
MagicStack/asyncpg#1342 ·
Tutte le issue di MagicStack/asyncpg
Issue simili
-
bug
Difficoltà 2/5 1-3 ore Idoneità per principianti 82/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 88/100
use-agent-os/agent-os#3314 ·
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 75/100
BasedHardware/omi#15662 · 1 commento ·
-
documentation help wanted
Difficoltà 2/5 1-3 ore Idoneità per principianti 90/100
-
Difficoltà 2/5 1-3 ore Idoneità per principianti 62/100
AiursoftWeb/AnduinOS-2#19 ·