jenkins-bot has submitted this change and it was merged.
Change subject: (bug 55127) Allow user to cut off pending network requests at shutdown
......................................................................
(bug 55127) Allow user to cut off pending network requests at shutdown
If an exception was raised, an extra message is shown to the user,
suggesting to use ctrl-c to abort processing. Otherwise this message
is only shown if the bot is running in verbose mode.
Change-Id: Ie5cf53f97877e61c30e19e10cc2c0fdee647dcac
---
M pywikibot/comms/http.py
1 file changed, 14 insertions(+), 3 deletions(-)
Approvals:
Xqt: Looks good to me, approved
jenkins-bot: Verified
diff --git a/pywikibot/comms/http.py b/pywikibot/comms/http.py
index 6a4c287..5e7407b 100644
--- a/pywikibot/comms/http.py
+++ b/pywikibot/comms/http.py
@@ -21,9 +21,11 @@
__version__ = '$Id$'
__docformat__ = 'epytext'
+import sys
import urllib
import logging
import atexit
+import time
try:
from httplib2 import SSLHandshakeError
@@ -86,9 +88,18 @@
def _flush():
for i in threads:
http_queue.put(None)
- pywikibot.log(u'Waiting for threads to finish... ')
- for i in threads:
- i.join()
+
+ message = u'Waiting for %i network thread(s) to finish. Press ctrl-c to
abort' % len(threads)
+ if hasattr(sys, 'last_type'):
+ # we quit because of an exception
+ print sys.last_type
+ pywikibot.critical(message)
+ else:
+ pywikibot.log(message)
+
+ while any(t for t in threads if t.isAlive()):
+ time.sleep(.1)
+
pywikibot.log(u"All threads finished.")
atexit.register(_flush)
--
To view, visit
https://gerrit.wikimedia.org/r/110866
To unsubscribe, visit
https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: merged
Gerrit-Change-Id: Ie5cf53f97877e61c30e19e10cc2c0fdee647dcac
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: Merlijn van Deen <valhallasw(a)arctus.nl>
Gerrit-Reviewer: Ladsgroup <ladsgroup(a)gmail.com>
Gerrit-Reviewer: Xqt <info(a)gno.de>
Gerrit-Reviewer: jenkins-bot <>