Psycopg ConnectionPool kann nicht schließenPython

Python-Programme
Anonymous
 Psycopg ConnectionPool kann nicht schließen

Post by Anonymous »

Ich habe dieses Beispiel aus der Psycopg-Dokumentation ausprobiert: < /p>

Code: Select all

from psycopg import conninfo
from psycopg_pool import ConnectionPool

from config import DB_HOST, DB_NAME, DB_PASSWORD, DB_PORT, DB_USER

with ConnectionPool(
conninfo=conninfo.make_conninfo(
dbname=DB_NAME,
user=DB_USER,
password=DB_PASSWORD,
host=DB_HOST,
port=DB_PORT,
)
) as pool:
with pool.connection() as conn:
conn.execute("SELECT 1")

with conn.cursor() as cur:
cur.execute("SELECT 1")
< /code>
Dieser Code wird sofort ohne Fehler ausgeführt, aber das Skript läuft eine Weile immer wieder und druckt die folgenden Warnungen: < /p>
couldn't stop thread 'pool-1-worker-0' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
couldn't stop thread 'pool-1-worker-1' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
couldn't stop thread 'pool-1-worker-2' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
couldn't stop thread 'pool-1-scheduler' within 5.0 seconds
hint: you can try to call 'close()' explicitly or to use the pool as context manager
< /code>
und endet schließlich, nachdem Sie diese Warnung zum 4. Mal gezeigt haben. Ich benutze den Pool als Kontextmanager. Ich habe auch versucht, Pool zu addieren. Was mache ich falsch? />  Die Datenbank wird in einem lokalen Docker -Container ausgeführt (postgres :: neuest2025-06-02 16:26:57.780 UTC [86] LOG:  statement: BEGIN
2025-06-02 16:26:57.780 UTC [86] LOG:  statement: SELECT 1
2025-06-02 16:26:57.781 UTC [86] LOG:  statement: COMMIT
2025-06-02 16:26:57.782 UTC [86] LOG:  statement: BEGIN
2025-06-02 16:26:57.782 UTC [86] LOG:  statement: SELECT EXISTS (SELECT 1 FROM pg_type WHERE typname = 'event_car');
2025-06-02 16:26:57.783 UTC [86] LOG:  statement: COMMIT
2025-06-02 16:26:57.783 UTC [86] LOG:  statement: BEGIN
2025-06-02 16:26:57.784 UTC [86] LOG:  statement: SELECT signal_name, signal_id FROM Signal
2025-06-02 16:26:57.785 UTC [86] LOG:  statement: COMMIT
2025-06-02 16:26:57.799 UTC [88] LOG:  statement: BEGIN
2025-06-02 16:26:57.799 UTC [88] LOG:  statement: SELECT 1
2025-06-02 16:26:57.800 UTC [88] LOG:  statement: SELECT 1
2025-06-02 16:26:57.800 UTC [88] LOG:  statement: COMMIT

Quick Reply

Change Text Case: 
   
  • Similar Topics
    Replies
    Views
    Last post