Identify and close specific connection in AsyncClient

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

メンテナーはふだん 1 日以内に返信

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

評価

難易度
5/5
見積もり時間
1週間以上
初心者へのやさしさ
35/100
issue の種類
機能追加
明瞭さ
説明が足りない
活発さ
静か
技術スタック
python
領域
api, backend

調査の方向性

この issue には、ファイル、テスト、コードのエントリーポイントが記載されていません。まず AsyncClient に文書化されている接続制御と、現在の connection-pool の動作を確認してください。調査を完了したら、接続単位の識別と選択的なクローズがサポートされているのか、それとも範囲を限定した設計が必要なのかを明らかにします。

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

説明

Originally opened by @BlackCloud37 on 2025-08-25 06:04:51 in encode/httpx

Hello,

I'm trying to use httpx(in asyncio) for my web scraper program.

In my use case, to prevent my connection from banning, I usually want to limit the request on single connection, which means:

  1. Close a connection after N requests.
  2. If a connection is banned, for example, received HTTP code 429 or any invalid response.

By reading the document, I cannot find any methods that I can:

  1. Identify each request's underlying connection, so I can count requests on certain connection.
  2. To close this single connection if satisfied any condition above.

So I currently implement this in "one connection per async client" way. I limited the max_connections to 1 for my client, and each time I want to drop a connection, I throw the client away and create a new one.

As the document says, it's a bad idea to do so. So is there any way I can reuse the clients for my purpose?

Any help would be much appreciated!

主要言語
Python
スター
1.6k
フォーク
103
平均マージ
1日 19時間
マージ済み PR(30日)
25

環境構築

はじめの一歩

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

pydantic/httpx2 のほかの issue

pydantic/httpx2 の issue をすべて見る

似ている issue

Python の issue をもっと見る

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

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