jenkins-bot has submitted this change and it was merged. ( https://gerrit.wikimedia.org/r/502518 )
Change subject: [IMPR] use pywikibot.sleep() in scripts to drop script from throttle control ......................................................................
[IMPR] use pywikibot.sleep() in scripts to drop script from throttle control
Change-Id: I399a211e1028949e302858b59c1c2b74aab547ec --- M scripts/add_text.py M scripts/clean_sandbox.py M scripts/replace.py M scripts/weblinkchecker.py 4 files changed, 9 insertions(+), 12 deletions(-)
Approvals: Dvorapa: Looks good to me, approved jenkins-bot: Verified
diff --git a/scripts/add_text.py b/scripts/add_text.py index 61b0ff2..c489f5d 100755 --- a/scripts/add_text.py +++ b/scripts/add_text.py @@ -66,7 +66,6 @@ import codecs import re import sys -import time
import pywikibot
@@ -110,7 +109,7 @@ except pywikibot.ServerError: if count <= config.max_retries: pywikibot.output('Server Error! Wait..') - time.sleep(config.retry_wait) + pywikibot.sleep(config.retry_wait) return None else: raise pywikibot.ServerError( diff --git a/scripts/clean_sandbox.py b/scripts/clean_sandbox.py index aab9f0b..ecc9d2b 100755 --- a/scripts/clean_sandbox.py +++ b/scripts/clean_sandbox.py @@ -29,9 +29,9 @@ # (C) Wikipedian, 2006-2007 # (C) Andre Engels, 2007 # (C) Siebrand Mazeland, 2007 -# (C) xqt, 2009-2018 +# (C) xqt, 2009-2019 # (C) Dr. Trigon, 2012 -# (C) Pywikibot team, 2010-2018 +# (C) Pywikibot team, 2010-2019 # # Distributed under the terms of the MIT license. # @@ -219,7 +219,7 @@ .format(edit_delta.seconds / 60.0)) pywikibot.output('Sleeping for {} minutes.' .format(delta.seconds // 60)) - time.sleep(delta.seconds) + pywikibot.sleep(delta.seconds) wait = True except pywikibot.EditConflict: pywikibot.output( @@ -238,7 +238,7 @@ else: pywikibot.output('\nSleeping {} hours, now {}' .format(self.getOption('hours'), now)) - time.sleep(self.getOption('hours') * 60 * 60) + pywikibot.sleep(self.getOption('hours') * 60 * 60)
def main(*args): diff --git a/scripts/replace.py b/scripts/replace.py index 691ce5e..339dfb5 100755 --- a/scripts/replace.py +++ b/scripts/replace.py @@ -149,7 +149,6 @@ except ImportError: # Python 2.7 from collections import Sequence import re -import time import warnings
import pywikibot @@ -627,8 +626,8 @@ exceptions = _get_text_exceptions(self.exceptions) skipped_containers = set() for replacement in self.replacements: - if self.sleep is not None: - time.sleep(self.sleep) + if self.sleep: + pywikibot.sleep(self.sleep) if (replacement.container and replacement.container.name in skipped_containers): continue diff --git a/scripts/weblinkchecker.py b/scripts/weblinkchecker.py index 748ee2c..e3d5d69 100755 --- a/scripts/weblinkchecker.py +++ b/scripts/weblinkchecker.py @@ -114,7 +114,6 @@ import time
from functools import partial -from time import sleep from warnings import warn
try: @@ -197,7 +196,7 @@ except (requests.ConnectionError, MementoClientException) as e: error = e retry_count += 1 - sleep(config2.retry_wait) + pywikibot.sleep(config2.retry_wait) else: raise error
@@ -894,7 +893,7 @@ # Limit the number of threads started at the same time. Each # thread will check one page, then die. while threading.activeCount() >= config.max_external_links: - time.sleep(config.retry_wait) + pywikibot.sleep(config.retry_wait) thread = LinkCheckThread(page, url, self.history, self.HTTPignore, self.day) # thread dies when program terminates
pywikibot-commits@lists.wikimedia.org