jenkins-bot has submitted this change. (
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698328 )
Change subject: [bugfix] clear put_queue when canceling page save
......................................................................
[bugfix] clear put_queue when canceling page save
The pywikibot._flush method is called twice. one time by BaseBot.exit()
which calls pywikibot.stopme() and the second time at exit time because
atexit registerd pywikibot._flush. But the queue isn't cleared.
Clear the queue if page saving is canceled.
Bug: T284396
Change-Id: Ie30a82ad52b9268ba3d8fedea89c36d7fee57de1
---
M pywikibot/__init__.py
1 file changed, 7 insertions(+), 6 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/__init__.py b/pywikibot/__init__.py
index 7fd8856..d102841 100644
--- a/pywikibot/__init__.py
+++ b/pywikibot/__init__.py
@@ -1306,6 +1306,11 @@
'Estimated time remaining: {}\nReally exit?'
.format(*remaining()),
default=False, automatic_quit=False):
+ # delete the put queue
+ with page_put_queue.mutex:
+ page_put_queue.all_tasks_done.notify_all()
+ page_put_queue.queue.clear()
+ page_put_queue.not_full.notify_all()
break
# only need one drop() call because all throttles use the same global pid
@@ -1333,12 +1338,8 @@
def async_request(request, *args, **kwargs):
"""Put a request on the queue, and start the daemon if
necessary."""
if not _putthread.is_alive():
- try:
- page_put_queue.mutex.acquire()
- with suppress(AssertionError, RuntimeError):
- _putthread.start()
- finally:
- page_put_queue.mutex.release()
+ with page_put_queue.mutex, suppress(AssertionError, RuntimeError):
+ _putthread.start()
page_put_queue.put((request, args, kwargs))
--
To view, visit
https://gerrit.wikimedia.org/r/c/pywikibot/core/+/698328
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: Ie30a82ad52b9268ba3d8fedea89c36d7fee57de1
Gerrit-Change-Number: 698328
Gerrit-PatchSet: 2
Gerrit-Owner: Xqt <info(a)gno.de>
Gerrit-Reviewer: Dvorapa <dvorapa(a)seznam.cz>
Gerrit-Reviewer: Mpaa <mpaa.wiki(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: Zhuyifei1999 <zhuyifei1999(a)gmail.com>
Gerrit-Reviewer: jenkins-bot
Gerrit-MessageType: merged