jenkins-bot has submitted this change. ( 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1246180?usp=email )

Change subject: FilePage.download: use read throttle with FilePage.download
......................................................................

FilePage.download: use read throttle with FilePage.download

This implementation is needed due to Wikitech robot policy
https://wikitech.wikimedia.org/wiki/Robot_policy#Media%20API%20rules

The delay is found by tests having config.mithrottle of 0.1 s

Bug: T418672
Change-Id: I2eb121ee59d574857fe0801b8a12c03287e66d0f
---
M pywikibot/page/_filepage.py
1 file changed, 6 insertions(+), 0 deletions(-)

Approvals:
  Xqt: Looks good to me, approved
  jenkins-bot: Verified




diff --git a/pywikibot/page/_filepage.py b/pywikibot/page/_filepage.py
index 5239bbf..318cebf 100644
--- a/pywikibot/page/_filepage.py
+++ b/pywikibot/page/_filepage.py
@@ -413,6 +413,12 @@
         path = path.with_suffix(Path(urlparse(url).path).suffix)
         # adjust user path
         path = path.expanduser()
+        # use read throttle per Wikitech robot policy for download (T418672)
+        # multiply minthrottle by 25 to get an functional delay
+        self.site.throttle.set_delays(delay=25 * self.site.throttle.delay)
+        self.site.throttle()
+        self.site.throttle.set_delays()
+
         req = http.fetch(url, stream=True)
         if req.status_code == HTTPStatus.OK:
             with open(path, 'wb') as f:

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1246180?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: I2eb121ee59d574857fe0801b8a12c03287e66d0f
Gerrit-Change-Number: 1246180
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <[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]

Reply via email to