MagicStack / MagicStack/asyncpg
How to remove log listeners for a pool:ed connections.
Nobody has claimed this yet.
- Dominant language
- Python
- Stars
- 8.1k
- Forks
- 468
- PR merge metrics
- No merged PRs in 30d
Description
According to the documentation the setup callback is where you should do stuff like add log listeners to the connection. It works fine but when the connection is release back to the pool I get a warning that it still have a active log listener, which is correct but misleading.
- How/where should I remove the log listener?
- Is there a
releasecallback somewhere that I have missed? - I see that the warning is made using the
warningspython api. I can just silence it but that might hide actual errors.
Example code:
pool = await asyncpg.create_pool(
user='postgres',
setup=lambda conn: conn.add_log_listener(_log_test),
)
After I have checked out a connection and released it back this gets printed to stdout/err:
/opt/python3.7/lib/python3.7/site-packages/asyncpg/connection.py:1295: InterfaceWarning: <wild.database.LeaderConnection object at 0x7f006d4e1208> is being released to the pool but has 1 active log listener
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start with the connection-pool documentation and the setup callback behavior described in the issue. Inspect asyncpg/connection.py around line 1295 to understand the active-listener warning and trace how connections are released. Done means the listener lifecycle is clear and the misleading warning or missing release mechanism is addressed without hiding unrelated warnings.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- postgresql, python
- Domain
- databases
- Issue type
- Feature
- Difficulty
- 4/5
- Estimated time
- 3-5 days
- Activity status
- Stale
- Clarity
- Mostly clear
- Newbie friendliness
- 35/100