jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225619?usp=email )
Change subject: get_delay: consider retry_after in delay calculation
......................................................................
get_delay: consider retry_after in delay calculation
Include any pending retry_after when computing the delay for read or
write operations. The returned value still incorporates process
concurrency via process_multiplicity.
Bug: T414354
Change-Id: I06e863e35cb8087b493b74bd7d7cdf958a8572f2
---
M pywikibot/throttle.py
1 file changed, 15 insertions(+), 7 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 0fe30ad..d0fd51f 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -10,7 +10,7 @@
on the number of concurrent bot instances, and optional lag-aware delays.
"""
#
-# (C) Pywikibot team, 2008-2025
+# (C) Pywikibot team, 2008-2026
#
# Distributed under the terms of the MIT license.
#
@@ -269,25 +269,33 @@
def get_delay(self, *, write: bool = False) -> float:
"""Return the current delay, adjusted for active processes.
- Compute the delay for a read or write operation, factoring in
- process concurrency. This method does not account for how much
- time has already passed since the last access — use
+ Computes the delay for a read or write operation, taking into
+ account process concurrency and any pending retry-after value.
+ The returned value already includes the
+ :attr:`process_multiplicity` factor. This method does not
+ consider how much time has passed since the last access — use
:meth:`waittime` for that.
.. versionadded:: 10.3.0
Renamed from :meth:`getDelay`.
+ .. versionchanged:: 11.0
+ The delay now takes any pending :attr:`retry_after` into
+ account.
:param write: Whether the operation is a write (uses writedelay).
:return: The delay in seconds before the next operation should
occur.
"""
- current_delay = self.writedelay if write else self.delay
-
# Refresh process count if the check interval has elapsed
if time.time() > self.checktime + self.checkdelay:
self.checkMultiplicity()
- current_delay = max(self.mindelay, min(current_delay, self.maxdelay))
+ current_delay = max(
+ self.mindelay,
+ self.retry_after,
+ min(self.writedelay if write else self.delay, self.maxdelay)
+ )
+
return current_delay * self.process_multiplicity
def waittime(self, write: bool = False):
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1225619?usp=email
To unsubscribe, or for help writing mail filters, visit
https://gerrit.wikimedia.org/r/settings?usp=email
Gerrit-MessageType: merged
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I06e863e35cb8087b493b74bd7d7cdf958a8572f2
Gerrit-Change-Number: 1225619
Gerrit-PatchSet: 10
Gerrit-Owner: Shivaansh Singh <[email protected]>
Gerrit-Reviewer: Xqt <[email protected]>
Gerrit-Reviewer: jenkins-bot
_______________________________________________
Pywikibot-commits mailing list -- [email protected]
To unsubscribe send an email to [email protected]