jenkins-bot submitted this change.
[IMPR] put_throttle may be given as float
Bug: T269741
Change-Id: I03a99539789222ea1d68ce63b458126033da3853
---
M pywikibot/__init__.py
M pywikibot/bot.py
M pywikibot/config2.py
M pywikibot/throttle.py
4 files changed, 10 insertions(+), 7 deletions(-)
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 163d437..d78ca2f 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1245,7 +1245,7 @@
remainingPages -= 1
remainingSeconds = datetime.timedelta(
- seconds=(remainingPages * config.put_throttle))
+ seconds=round(remainingPages * config.put_throttle))
return (remainingPages, remainingSeconds)
if stop:
diff --git a/pywikibot/bot.py b/pywikibot/bot.py
index 82fc233..4e03769 100644
--- a/pywikibot/bot.py
+++ b/pywikibot/bot.py
@@ -778,7 +778,7 @@
elif option == '-user':
username = value
elif option in ('-putthrottle', '-pt'):
- config.put_throttle = int(value)
+ config.put_throttle = float(value)
elif option == '-log':
if module_name not in config.log:
config.log.append(module_name)
diff --git a/pywikibot/config2.py b/pywikibot/config2.py
index 120b404..753d587 100644
--- a/pywikibot/config2.py
+++ b/pywikibot/config2.py
@@ -48,7 +48,7 @@
from locale import getdefaultlocale
from os import getenv, environ
from textwrap import fill
-from typing import Optional
+from typing import Optional, Union
from warnings import warn
from pywikibot.__metadata__ import __version__ as pwb_version
@@ -636,7 +636,7 @@
# Slow down the robot such that it never makes a second page edit within
# 'put_throttle' seconds.
-put_throttle = 10
+put_throttle = 10 # type: Union[int, float]
# Sometimes you want to know when a delay is inserted. If a delay is larger
# than 'noisysleep' seconds, it is logged on the screen.
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index 89fe2b1..a11f992 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -11,7 +11,7 @@
from collections import namedtuple
from contextlib import suppress
-from typing import Optional
+from typing import Optional, Union
import pywikibot
from pywikibot import config
@@ -42,8 +42,11 @@
"""
- def __init__(self, site, mindelay=None, maxdelay=None, writedelay=None,
- multiplydelay=True):
+ def __init__(self, site,
+ mindelay: Optional[int] = None,
+ maxdelay: Optional[int] = None,
+ writedelay: Union[int, float, None] = None,
+ multiplydelay: bool = True):
"""Initializer."""
self.lock = threading.RLock()
self.lock_write = threading.RLock()
To view, visit change 647653. To unsubscribe, or for help writing mail filters, visit settings.