MagicStack / MagicStack/asyncpg

How to remove log listeners for a pool:ed connections.

オープン
#377 コメント 8 件 リアクション 0 件 担当者 0 名 GitHub で見る

まだ誰も着手していません。

主要言語
Python
スター
8.1k
フォーク
468
PR マージ指標
30日以内にマージされた PR はありません

説明

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 release callback somewhere that I have missed?
  • I see that the warning is made using the warnings python 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

コントリビューションガイド

このリポジトリのコントリビューションガイドは索引されていません

はじめの一歩

  1. issue を最後まで読み、次にプロジェクトのコントリビューションガイドを読みます。
  2. 着手することを issue にコメントします — 二人が同じ作業をするのを防げます。
  3. リポジトリをフォークし、ブランチを切って変更します。
  4. issue 番号を参照したプルリクエストを送ります。

調査の方向性

まず、issue に記載されている connection-pool のドキュメントと setup callback の動作から確認します。asyncpg/connection.py の 1295 行付近を調べて active-listener warning の意味を理解し、接続がどのように解放されるかを追跡してください。listener のライフサイクルが明確になり、誤解を招く warning または不足している解放メカニズムが、無関係な warning を隠すことなく対処されれば完了です。

索引モデルが issue の本文から書いたものです。

評価

技術スタック
postgresql, python
領域
databases
issue の種類
機能追加
難易度
4/5
見積もり時間
3〜5日
活発さ
停滞
明瞭さ
おおむね明確
初心者へのやさしさ
35/100

新しい issue をメールで受け取る

初心者向けの GitHub issue を短くまとめたダイジェスト。