XZise has uploaded a new change for review.

  https://gerrit.wikimedia.org/r/186596

Change subject: [FIX] Pagegen: Exit intersect if a gen is empty
......................................................................

[FIX] Pagegen: Exit intersect if a gen is empty

If a generator is already empty before the intersect_generator is
started it shouldn't initialize anything and always return immediately.
Otherwise the ThreadedGenerator throws an RuntimeError because it treats
an empty generator as no generator.

Bug: T85667
Change-Id: I36908a79adb7d8c692af40725e343b021354aba5
---
M pywikibot/tools.py
1 file changed, 9 insertions(+), 2 deletions(-)


  git pull ssh://gerrit.wikimedia.org:29418/pywikibot/core 
refs/changes/96/186596/1

diff --git a/pywikibot/tools.py b/pywikibot/tools.py
index 3d45090..448e100 100644
--- a/pywikibot/tools.py
+++ b/pywikibot/tools.py
@@ -361,7 +361,14 @@
     @param genlist: list of page generators
     @type genlist: list
     """
-    _logger = ""
+    _logger = "intersect"
+
+    # If any generator is empty, no pages are going to be returned
+    for source in genlist:
+        if not source:
+            debug('At least one generator ({0!r}) is empty and execution was '
+                  'skipped immediately.'.format(source), _logger)
+            return
 
     # Item is cached to check that it is found n_gen
     # times before being yielded.
@@ -375,7 +382,7 @@
     for source in genlist:
         threaded_gen = ThreadedGenerator(name=repr(source), target=source)
         thrlist.append(threaded_gen)
-        debug("INTERSECT: thread started: %r" % threaded_gen, _logger)
+        debug("thread started: %r" % threaded_gen, _logger)
 
     while True:
         # Get items from queues in a round-robin way.

-- 
To view, visit https://gerrit.wikimedia.org/r/186596
To unsubscribe, visit https://gerrit.wikimedia.org/r/settings

Gerrit-MessageType: newchange
Gerrit-Change-Id: I36908a79adb7d8c692af40725e343b021354aba5
Gerrit-PatchSet: 1
Gerrit-Project: pywikibot/core
Gerrit-Branch: master
Gerrit-Owner: XZise <[email protected]>

_______________________________________________
MediaWiki-commits mailing list
[email protected]
https://lists.wikimedia.org/mailman/listinfo/mediawiki-commits

Reply via email to