How can I limit the number of requests made per second?

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

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

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

評価

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

調査の方向性

リンクされている httpx のコネクションプールに関する議論と、参照されている issue コメントから始めてください。単位時間あたりのレート制限がすでにサポートされているのか、それとも新しい設計が必要なのかを判断してください。アプローチが決定されるか、リクエストへの回答が文書化されれば完了です。

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

説明

Originally opened by @Midnighter on 2020-02-13 17:18:17 in encode/httpx

In this comment @florimondmanca suggests that the connection pool limits can be used to rate-limit the number of requests made. I can see, of course, how setting those limits will constrain the number of 'concurrent' requests made by httpx. However, what if I want to limit the number of requests made per unit of time?

Say the API I'm hitting allows 10 requests per second, I guess a naive approach would be to set the hard limit of the connection pool to 10 and asyncio.sleep 1/10 s after every request. Does that sound about right or am I missing something obvious?

主要言語
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 を短くまとめたダイジェスト。