Nullzero has uploaded a new change for review.

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

Change subject: Speeding up touch.py by setting async=True
......................................................................

Speeding up touch.py by setting async=True

Since touch.py does not involve user interaction, it can use async=True
to speed up the running time. async=True can be used safely because this
script does not alter content of any page.

Change-Id: I35ed1615a907828bb035219b8b992d1c649a601f
---
M scripts/touch.py
1 file changed, 3 insertions(+), 16 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/82/141682/1

diff --git a/scripts/touch.py b/scripts/touch.py
index 44bb153..95e0f5d 100755
--- a/scripts/touch.py
+++ b/scripts/touch.py
@@ -49,26 +49,13 @@
                 pywikibot.output(u'Page %s%s purged'
                                  % (page.title(asLink=True),
                                     "" if page.purge() else " not"))
-                continue
-            try:
+            else:
                 # get the page, and save it using the unmodified text.
                 # whether or not getting a redirect throws an exception
                 # depends on the variable self.touch_redirects.
                 page.get(get_redirect=self.getOption('redir'))
-                page.save("Pywikibot touch script")
-            except pywikibot.NoPage:
-                pywikibot.error(u"Page %s does not exist."
-                                % page.title(asLink=True))
-            except pywikibot.IsRedirectPage:
-                pywikibot.warning(u"Page %s is a redirect; skipping."
-                                  % page.title(asLink=True))
-            except pywikibot.LockedPage:
-                pywikibot.error(u"Page %s is locked."
-                                % page.title(asLink=True))
-            except pywikibot.PageNotSaved:
-                pywikibot.error(u"Page %s not saved."
-                                % page.title(asLink=True))
-
+                # Save the page in the background. No need to catch exceptions.
+                page.save("Pywikibot touch script", async=True)
 
 def main(*args):
     gen = None

-- 
To view, visit https://gerrit.wikimedia.org/r/141682
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I35ed1615a907828bb035219b8b992d1c649a601f
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Nullzero <nullzero.f...@gmail.com>

_______________________________________________
MediaWiki-commits mailing list
MediaWiki-commits@lists.wikimedia.org
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to