From d9d05a062c6d9187e6feb85594750ae430222455 Mon Sep 17 00:00:00 2001
From: Doug Hellmann <doug@doughellmann.com>
Date: Fri, 26 Jan 2018 09:53:57 -0500
Subject: [PATCH] only start the link checkers when there are links to check

Do not start the ThreadPool when there are no links to check.

Change-Id: I355ea5af5d937e6b5d4cf481d9a29c6d3b123f09
Signed-off-by: Doug Hellmann <doug@doughellmann.com>
---
 tools/www-generator.py | 33 +++++++++++++++++----------------
 1 file changed, 17 insertions(+), 16 deletions(-)

diff --git a/tools/www-generator.py b/tools/www-generator.py
index 7d99ff197c..5d7cebba10 100755
--- a/tools/www-generator.py
+++ b/tools/www-generator.py
@@ -302,23 +302,24 @@ def load_project_data(source_directory,
                             (url, project['name'], flag, flag_val)
                         )
 
-        logger.info('checking %s links from %s...',
-                    len(links_to_check), filename)
-        pool = multiprocessing.pool.ThreadPool()
-        results = pool.map(_check_url, links_to_check)
+        if links_to_check:
+            logger.info('checking %s links from %s...',
+                        len(links_to_check), filename)
+            pool = multiprocessing.pool.ThreadPool()
+            results = pool.map(_check_url, links_to_check)
 
-        for url, project_name, flag, flag_val, exists, status in results:
-            if flag_val and not exists:
-                logger.error(
-                    '%s set for %s but %s does not exist (%s)',
-                    flag, project_name, url, status,
-                )
-                fail = True
-            elif (not flag_val) and check_all_links and exists:
-                logger.warning(
-                    '%s not set for %s but %s does exist',
-                    flag, project_name, url,
-                )
+            for url, project_name, flag, flag_val, exists, status in results:
+                if flag_val and not exists:
+                    logger.error(
+                        '%s set for %s but %s does not exist (%s)',
+                        flag, project_name, url, status,
+                    )
+                    fail = True
+                elif (not flag_val) and check_all_links and exists:
+                    logger.warning(
+                        '%s not set for %s but %s does exist',
+                        flag, project_name, url,
+                    )
 
         if fail:
             raise ValueError('invalid input in %s' % filename)