John Vandenberg has uploaded a new change for review.
https://gerrit.wikimedia.org/r/184285
Change subject: Prevent hang in LiveRCPageGenerator
......................................................................
Prevent hang in LiveRCPageGenerator
The socketio client is being disconnected, but continues to poll
for new items indefinitely.
Detect disconnection and stop polling, making LiveRCPageGenerator
fail to fetch the requested total number of items instead of
stalling.
Correct item counter so that the thread quits after total
instead of total+1.
And fix an invocation of warning() which used the syntax of debug(),
which is slightly different and fails when used for warning().
Bug: T85717
Change-Id: I0748938b5fbe22a70e032f909c61d3c5bd2b7034
---
M pywikibot/comms/rcstream.py
1 file changed, 6 insertions(+), 7 deletions(-)
git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core
refs/changes/85/184285/1
diff --git a/pywikibot/comms/rcstream.py b/pywikibot/comms/rcstream.py
index f3282ac..7baaadb 100644
--- a/pywikibot/comms/rcstream.py
+++ b/pywikibot/comms/rcstream.py
@@ -85,17 +85,16 @@
debug('Received change %r' % change, _logger)
thread.count += 1
- if thread.total is not None and thread.count > thread.total:
- thread.stop()
- return
-
thread.queue.put(change)
if thread.queue.qsize() > thread.warn_queue_length:
warning('%r queue length exceeded %i'
% (thread,
- thread.warn_queue_length),
- _logger=_logger)
+ thread.warn_queue_length))
thread.warn_queue_length = thread.warn_queue_length + 100
+
+ if thread.total is not None and thread.count >= thread.total:
+ thread.stop()
+ return
def on_connect(self):
debug('Connected to %r; subscribing to %s'
@@ -115,7 +114,7 @@
def run(self):
""" Threaded function. Runs insided the thread when started with
.start(). """
self.running = True
- while self.running:
+ while self.running and self.client.connected:
self.client.wait(seconds=0.1)
debug('Shut down event loop for %r' % self, _logger)
self.client.disconnect()
--
To view, visit https://gerrit.wikimedia.org/r/184285
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings
Gerrit-MessageType: newchange
Gerrit-Change-Id: I0748938b5fbe22a70e032f909c61d3c5bd2b7034
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: John Vandenberg <[email protected]>
_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits