jenkins-bot has submitted this change and it was merged.
Change subject: [IMPROV] Pagegen: Exit intersect if a gen is empty ......................................................................
[IMPROV] 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 to avoid creating any nonsensical threads.
Change-Id: I36908a79adb7d8c692af40725e343b021354aba5 --- M pywikibot/tools.py 1 file changed, 7 insertions(+), 0 deletions(-)
Approvals: John Vandenberg: Looks good to me, approved jenkins-bot: Verified
diff --git a/pywikibot/tools.py b/pywikibot/tools.py index e3cf994..dd5ec2c 100644 --- a/pywikibot/tools.py +++ b/pywikibot/tools.py @@ -418,6 +418,13 @@ @param genlist: list of page generators @type genlist: list """ + # 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), 'intersect') + return + # Item is cached to check that it is found n_gen # times before being yielded. cache = collections.defaultdict(set)
pywikibot-commits@lists.wikimedia.org