jenkins-bot has submitted this change and it was merged. (
https://gerrit.wikimedia.org/r/437145 )
Change subject: throttle.py: use different locks for read/write actions
......................................................................
throttle.py: use different locks for read/write actions
Use different locks for read and write actions
An async save (write actions via _putthread) would not block read
actions in Main thread.
Bug: T135992
Change-Id: Ic73f0e5556f8533c136b64e6d23f02ee6f2dfad7
---
M pywikibot/throttle.py
1 file changed, 4 insertions(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/throttle.py b/pywikibot/throttle.py
index e6236ff..ef0367e 100644
--- a/pywikibot/throttle.py
+++ b/pywikibot/throttle.py
@@ -41,6 +41,8 @@
multiplydelay=True):
"""Initializer."""
self.lock = threading.RLock()
+ self.lock_write = threading.RLock()
+ self.lock_read = threading.RLock()
self.mysite = str(site)
self.ctrlfilename = config.datafilepath('throttle.ctrl')
self.mindelay = mindelay
@@ -260,7 +262,8 @@
thread from writing to the same site until the wait expires.
"""
- with self.lock:
+ lock = self.lock_write if write else self.lock_read
+ with lock:
wait = self.waittime(write=write)
# Calculate the multiplicity of the next delay based on how
# big the request is that is being posted now.
--
To view, visit
https://gerrit.wikimedia.org/r/437145
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-MessageType: merged
Gerrit-Change-Id: Ic73f0e5556f8533c136b64e6d23f02ee6f2dfad7
Gerrit-Change-Number: 437145
Gerrit-PatchSet: 1
Gerrit-Owner: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: John Vandenberg <jayvdb(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: jenkins-bot <>