jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1337396?usp=email )
Change subject: wikistats: Isolate cached tables by server URL
......................................................................
wikistats: Isolate cached tables by server URL
The global cache identifies responses only by table name, so instances
using different servers can return data fetched from the first server.
Include the server URL in the cache key after normalizing the family
alias. Instances using the same server continue to share cached tables.
Change-Id: If012dcfe7fef927757971e897ecf82058519bbe5
---
M pywikibot/data/wikistats.py
1 file changed, 5 insertions(+), 4 deletions(-)
Approvals:
jenkins-bot: Verified
Xqt: Looks good to me, approved
diff --git a/pywikibot/data/wikistats.py b/pywikibot/data/wikistats.py
index c48f0a5..2de69b4 100644
--- a/pywikibot/data/wikistats.py
+++ b/pywikibot/data/wikistats.py
@@ -15,7 +15,7 @@
# cache the data
-_data: dict[str, list[Any]] = {}
+_data: dict[tuple[str, str], list[Any]] = {}
class WikiStats:
@@ -93,8 +93,9 @@
:param table: table of data to fetch
"""
table = self.FAMILY_MAPPING.get(table, table)
- if table in _data:
- return _data[table]
+ cache_key = (self.url, table)
+ if cache_key in _data:
+ return _data[cache_key]
if table not in self.ALL_KEYS:
pywikibot.warning('WikiStats unknown table ' + table)
@@ -108,7 +109,7 @@
f = StringIO(r.text)
reader = DictReader(f)
data = list(reader)
- _data[table] = data
+ _data[cache_key] = data
return data
def get_dict(self, table: str) -> dict:
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/1337396?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: If012dcfe7fef927757971e897ecf82058519bbe5
Gerrit-Change-Number: 1337396
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]