jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/628580 )
Change subject: [bugfix] Check whether _putthead is current_thread() to join()
......................................................................
[bugfix] Check whether _putthead is current_thread() to join()
Do not _putthread.join() if _putthead is not current_thread().
Otherwise a RuntimeError is raised to prevent a deadlock.
Also break the while loop during KeyboardInterrupt to drop all
throttles.
Bug: T263331
Change-Id: If79741b4f29c2ef48f5a1a14c1873c73d983fc2c
---
M pywikibot/__init__.py
1 file changed, 12 insertions(+), 11 deletions(-)
Approvals:
Zhuyifei1999: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 97dadda..cfc2c0d 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1349,17 +1349,18 @@
'{lightblue}Waiting for {num} pages to be put. '
'Estimated time remaining: {sec}{default}', num=num, sec=sec))
- while (_putthread.is_alive()
- and (page_put_queue.qsize() > 0
- or page_put_queue_busy.qsize() > 0)):
- try:
- _putthread.join(1)
- except KeyboardInterrupt:
- if input_yn('There are {} pages remaining in the queue. '
- 'Estimated time remaining: {}\nReally exit?'
- .format(*remaining()),
- default=False, automatic_quit=False):
- return
+ if _putthread is not threading.current_thread():
+ while (_putthread.is_alive()
+ and (page_put_queue.qsize() > 0
+ or page_put_queue_busy.qsize() > 0)):
+ try:
+ _putthread.join(1)
+ except KeyboardInterrupt:
+ if input_yn('There are {} pages remaining in the queue. '
+ 'Estimated time remaining: {}\nReally exit?'
+ .format(*remaining()),
+ default=False, automatic_quit=False):
+ break
# only need one drop() call because all throttles use the same global pid
with suppress(IndexError):
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/628580
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: If79741b4f29c2ef48f5a1a14c1873c73d983fc2c
Gerrit-Change-Number: 628580
Gerrit-PatchSet: 3
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/629083 )
Change subject: [date] show a FutureWarning for deprecated MakeParameter function
......................................................................
[date] show a FutureWarning for deprecated MakeParameter function
Change-Id: I433fdcc69d52c35f207b51d754b0f5c62f519476
---
M pywikibot/date.py
1 file changed, 3 insertions(+), 3 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/date.py b/pywikibot/date.py
index c01700f..9d0bf50 100644
--- a/pywikibot/date.py
+++ b/pywikibot/date.py
@@ -15,7 +15,7 @@
from pywikibot import Site
from pywikibot.textlib import NON_LATIN_DIGITS
-from pywikibot.tools import first_lower, first_upper, deprecated
+from pywikibot.tools import deprecated, first_lower, first_upper
#
# Different collections of well known formats
@@ -310,7 +310,7 @@
# Each tuple must 3 parts: a list of all possible digits (symbols), encoder
-# (from int to a u-string) and decoder (from u-string to an int)
+# (from int to a str) and decoder (from str to an int)
_digitDecoders = {
# %% is a %
'%': '%',
@@ -485,7 +485,7 @@
return newValue
-@deprecated(since='20151014')
+@deprecated(since='20151014', future_warning=True)
def MakeParameter(decoder, param):
"""DEPRECATED."""
return _make_parameter(decoder, param)
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/629083
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I433fdcc69d52c35f207b51d754b0f5c62f519476
Gerrit-Change-Number: 629083
Gerrit-PatchSet: 1
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/629087 )
Change subject: [IMPR] Use functools.cache for _code_fam_from_url function
......................................................................
[IMPR] Use functools.cache for _code_fam_from_url function
Change-Id: I5b159c6c6397f1bce9c24946eb56c1b8e87596cc
---
M pywikibot/__init__.py
M tests/utils.py
2 files changed, 28 insertions(+), 24 deletions(-)
Approvals:
Mpaa: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 97dadda..041dcfa 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -63,11 +63,18 @@
issue_deprecation_warning,
normalize_username,
MediaWikiVersion as _MediaWikiVersion,
- redirect_func,
ModuleDeprecationWrapper as _ModuleDeprecationWrapper,
+ PYTHON_VERSION,
+ redirect_func,
)
from pywikibot.tools.formatter import color_format
+if PYTHON_VERSION >= (3, 9, 0):
+ from functools import cache
+else:
+ from functools import lru_cache
+ cache = lru_cache(None)
+
textlib_methods = (
'categoryFormat', 'compileLinkR', 'extract_templates_and_params',
@@ -1136,36 +1143,33 @@
_sites = {}
-_url_cache = {} # The code/fam pair for each URL
-def _code_fam_from_url(url):
+@cache
+def _code_fam_from_url(url: str):
"""Set url to cache and get code and family from cache.
Site helper method.
@param url: The site URL to get code and family
- @type url: str
@raises pywikibot.exceptions.SiteDefinitionError: Unknown URL
"""
- if url not in _url_cache:
- matched_sites = []
- # Iterate through all families and look, which does apply to
- # the given URL
- for fam in config.family_files:
- family = Family.load(fam)
- code = family.from_url(url)
- if code is not None:
- matched_sites.append((code, family))
+ matched_sites = []
+ # Iterate through all families and look, which does apply to
+ # the given URL
+ for fam in config.family_files:
+ family = Family.load(fam)
+ code = family.from_url(url)
+ if code is not None:
+ matched_sites.append((code, family))
- if not matched_sites:
- # TODO: As soon as AutoFamily is ready, try and use an
- # AutoFamily
- raise SiteDefinitionError("Unknown URL '{0}'.".format(url))
- if len(matched_sites) > 1:
- warning('Found multiple matches for URL "{0}": {1} (use first)'
- .format(url, ', '.join(str(s) for s in matched_sites)))
- _url_cache[url] = matched_sites[0]
- return _url_cache[url]
+ if not matched_sites:
+ # TODO: As soon as AutoFamily is ready, try and use an
+ # AutoFamily
+ raise SiteDefinitionError("Unknown URL '{}'.".format(url))
+ if len(matched_sites) > 1:
+ warning('Found multiple matches for URL "{}": {} (use first)'
+ .format(url, ', '.join(str(s) for s in matched_sites)))
+ return matched_sites[0]
@_deprecate_arg('sysop', None)
diff --git a/tests/utils.py b/tests/utils.py
index 0bea97d..2dbab7b 100644
--- a/tests/utils.py
+++ b/tests/utils.py
@@ -641,7 +641,7 @@
@contextmanager
def empty_sites():
- """Empty pywikibot._sites and pywikibot._url_cache cache on entry point."""
+ """Empty pywikibot _sites and _code_fam_from_url cache on entry point."""
pywikibot._sites = {}
- pywikibot._url_cache = {}
+ pywikibot._code_fam_from_url.cache_clear()
yield
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/629087
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I5b159c6c6397f1bce9c24946eb56c1b8e87596cc
Gerrit-Change-Number: 629087
Gerrit-PatchSet: 5
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged
jenkins-bot has submitted this change. ( https://gerrit.wikimedia.org/r/c/pywikibot/core/+/628628 )
Change subject: Credits: Rename "Zoranzoki21" to "Zoran Dori"
......................................................................
Credits: Rename "Zoranzoki21" to "Zoran Dori"
My account Zoranzoki21 is renamed to Kizule on Wikimedia's projects,
but I would like to in CREDITS be my real name and surname,
instead of username.
Change-Id: I19a39415f7d994a1b834048b99d76d803ff2a507
---
M CREDITS
1 file changed, 1 insertion(+), 1 deletion(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/CREDITS b/CREDITS
index a9bb833..7c74f1f 100644
--- a/CREDITS
+++ b/CREDITS
@@ -192,4 +192,4 @@
Yusuke Matsubara
Zaher Kadour
zhuyifei1999
-Zoranzoki21
+Zoran Dori
--
To view, visit https://gerrit.wikimedia.org/r/c/pywikibot/core/+/628628
To unsubscribe, or for help writing mail filters, visit https://gerrit.wikimedia.org/r/settings
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Change-Id: I19a39415f7d994a1b834048b99d76d803ff2a507
Gerrit-Change-Number: 628628
Gerrit-PatchSet: 2
Gerrit-Owner: Zoranzoki21 <zorandori4444(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged