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 <[email protected]>
Gerrit-Reviewer: Merlijn van Deen <[email protected]>
Gerrit-Reviewer: Zhuyifei1999 <[email protected]>
Gerrit-Reviewer: jenkins-bot
Gerrit-CC: Mpaa <[email protected]>
Gerrit-MessageType: merged
_______________________________________________
Pywikibot-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/pywikibot-commits

Reply via email to