我正在运行一个单线程脚本,该脚本使用来自 G Suite Sheets API 的数据。
一段时间后,日志中会弹出以下 429 HTTP 错误:
"Quota exceeded for quota group 'ReadGroup' and limit 'Read requests per user per 100 seconds' of service 'sheets.googleapis.com' for consumer...
我的配额限制默认设置如下(Ilimitado表示无限制):
我的客户在错误之前的最后一条日志行:
[2020-05-14 02:21:37,114: INFO/ForkPoolWorker-1] URL being requested: GET https://sheets.googleapis.com/v4/spreadsheets/<SHEET_ID>?alt=json
[2020-05-14 02:21:37,517: WARNING/ForkPoolWorker-1] Sleeping 1.19 seconds before retry 1 of 5 for request: GET https://sheets.googleapis.com/v4/spreadsheets/<SHEET_ID>?alt=json, after 429
[2020-05-14 02:21:39,057: WARNING/ForkPoolWorker-1] Sleeping 2.68 seconds before retry 2 of 5 for request: GET https://sheets.googleapis.com/v4/spreadsheets/<SHEET_ID>?alt=json, after 429
[2020-05-14 02:21:42,089: WARNING/ForkPoolWorker-1] Sleeping 3.16 seconds before retry 3 of 5 for request: GET https://sheets.googleapis.com/v4/spreadsheets/<SHEET_ID>?alt=json, after 429
[2020-05-14 02:21:45,606: WARNING/ForkPoolWorker-1] Sleeping 0.77 seconds before retry 4 of 5 for request: GET https://sheets.googleapis.com/v4/spreadsheets/<SHEET_ID>?alt=json, after 429
[2020-05-14 02:21:46,722: WARNING/ForkPoolWorker-1] Sleeping 20.65 seconds before retry 5 of 5 for request: GET https://sheets.googleapis.com/v4/spreadsheets/<SHEET_ID>?alt=json, after 429
[2020-05-14 02:22:07,735: WARNING/ForkPoolWorker-1] sheets#sheet: HTTP error (code 429): Quota exceeded for quota group...
我可以在这里识别库中的某种指数退避重试算法googleapiclient
,但我想知道的是(特别是在 20.65 秒暂停之后)为什么服务器仍然无法响应 2XX HTTP 响应。
- 是否需要等待 100 秒间隔结束,一旦收到前 100 个请求,然后再使用下一个 100 个请求?
- 如果是这样,我怎么能在不修改配额的情况下规避这一点?
感谢您的时间。