Page MenuHomePhabricator

retry-after is not respected except there is a server lag reported via API
Closed, ResolvedPublicBUG REPORT

Description

comms.http.request catches any retry-after and stores its value with the Throttle object of the current site. But this is only used with Throttle.lag() which is called by Request.submit if the Action API has a maxlag code. Recently the Wikimedia frontend restricts API calls and gives a 429 http code with retry-after value. This is not respected yet but a wait cycle is started and the wait cycle delay is mostly greater than the given retry-after value. Anyway the retry-after should be respected with the next API access.

Event Timeline

Xqt triaged this task as High priority.Jan 12 2026, 3:56 PM
Xqt changed the subtype of this task from "Task" to "Bug Report".

Change #1225619 had a related patch set uploaded (by Shivaansh Singh; author: Shivaansh Singh):

[pywikibot/core@master] Subject - Fix HTTP 429 handling to respect Retry-After header (T414354)

https://gerrit.wikimedia.org/r/1225619

Change #1225619 had a related patch set uploaded (by Shivaansh Singh; author: Shivaansh Singh):

[pywikibot/core@master] Add setuptools dependency to fix test failures

https://gerrit.wikimedia.org/r/1225619

Implementation idea:
The retry-after value is already read from response header and stored in throttle.retry_after attribute of the current site.

Throttle.get_delay():

  • Calculate current_delay as the maximum of
    • writedelay and retry_after value, or
    • delay and retry_after value
  • If retry_after is taken into account, clear it.
  • That's it? Yes that should be sufficient in most cases.

Advanced features:

  • Instead of using Throttle.process_multiplicity which counts the parallel processes of the current site, take all parallel processes instead.
  • increase config.putthrottle if 429 error was triggered by a write action and config.minthrottle for read requests.
Xqt claimed this task.

Change #1225619 merged by jenkins-bot:

[pywikibot/core@master] get_delay: consider retry_after in delay calculation

https://gerrit.wikimedia.org/r/1225619