Hacktoberfest 2026: le issue che i maintainer hanno segnato per ottobre, aperte e adatte ai principianti. Sfoglia le issue Hacktoberfest

Support a Pool `before_connect` callback to be used before a connection is created

Aperta
#1,118 2 commenti 0 reazioni 0 assegnatari Vedi su GitHub

Nessuno ha ancora preso questa issue.

Valutazione

Difficoltà
4/5
Tempo stimato
3-5 giorni
Idoneità per principianti
35/100
Tipo di issue
Funzionalità
Chiarezza
Abbastanza chiara
Stato di attività
Ferma
Stack tecnologico
postgresql, python
Ambito
database

Direzione di ricerca

Inizia da asyncpg/pool.py, in particolare dal callback init esistente e dai percorsi acquire/set_connect_args descritti nell’issue, per capire quando vengono create le connessioni e quando vengono prelevate dal pool. Il lavoro è completato quando un hook before-connect può aggiornare le credenziali dinamiche solo quando viene creata una nuova connessione del pool, anziché a ogni acquire.

Scritto dal modello di indicizzazione a partire dal testo della issue.

Descrizione

  • asyncpg version: 0.27.0
  • PostgreSQL version: 14
  • Do you use a PostgreSQL SaaS? If so, which? Can you reproduce
    the issue with a local PostgreSQL install?
    : Local
  • Python version: 3.9.9
  • Platform: macos
  • Do you use pgbouncer?: no
  • 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?
    :

Hello! This is more of a feature request but I was wondering if there could be support for having a before_connect or similar callback when creating a Pool object that would run before a new connection is created? I see there is already an init param which is run after a connection is made.

Our use case is that we use dynamic credentials to access our postgres database and want to make sure that when we create a connection we are using credentials that are not stale. Is this something that makes sense for this project? There is similar functionality in other libraries such as sqlalchemy or pgx.

I was looking at how to do this as-is and there were two currently that I was exploring. One way would be to create our own Pool class which seems like a lot of maintainance for what we'd like to do. The other looked at creating a subclass and overriding the acquire and using set_connect_args but that would run every time we get a connection from a pool which would be wasteful as opposed to just when the creation happens.

Lingua principale
Python
Stelle
8.1k
Fork
469
Merge medio
2g 20h
PR unite (30g)
9

Guida per i contributori

Nessuna guida per i contributori indicizzata per questo repository

Come iniziare

  1. Leggi tutta la issue e poi la guida ai contributi del progetto.
  2. Commenta sulla issue per dire che te ne occupi tu — evita che due persone facciano lo stesso lavoro.
  3. Fai un fork del repository e lavora su un branch.
  4. Apri una pull request che faccia riferimento al numero della issue.

Altre issue di MagicStack/asyncpg

Tutte le issue di MagicStack/asyncpg

Issue simili

Altre issue su Python

Ricevi le nuove issue nella tua casella

Un breve riepilogo di issue GitHub adatte ai principianti.