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

Change subject: touch: Avoid recalculating cached purge rate limits
......................................................................

touch: Avoid recalculating cached purge rate limits

setdefault() evaluates ratelimit('purge') for every page even when
the site already has a cached limit. Check the cache first so the
limit is calculated only once per site.

Change-Id: I9fbfb0edc3c7bdef7fc3ba3b737c071ce49d52ca
---
M scripts/touch.py
1 file changed, 2 insertions(+), 1 deletion(-)

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




diff --git a/scripts/touch.py b/scripts/touch.py
index 5a494a9..f81622d 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -94,7 +94,8 @@
         """
         # We can have multiple sites, save pages and cache rate limit
         self.pages[page.site].append(page)
-        self.limit.setdefault(page.site, page.site.ratelimit('purge'))
+        if page.site not in self.limit:
+            self.limit[page.site] = page.site.ratelimit('purge')
         self.purgepages()

     def teardown(self) -> None:

--
To view, visit 
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1337398?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: I9fbfb0edc3c7bdef7fc3ba3b737c071ce49d52ca
Gerrit-Change-Number: 1337398
Gerrit-PatchSet: 2
Gerrit-Owner: Mahveotm <[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