Blame SOURCES/oscap-anaconda-addon-1.2.2-content_ident-PR_167.patch

fa6af9
From 1abc4e96638e819d3fbee74396b36a6ccaf0ab29 Mon Sep 17 00:00:00 2001
fa6af9
From: Matej Tyc <matyc@redhat.com>
fa6af9
Date: Tue, 3 Aug 2021 11:01:59 +0200
fa6af9
Subject: [PATCH] Refactor content identification
fa6af9
fa6af9
Don't use the multiprocessing pool - it sometimes creates probems during
fa6af9
its initialization:
fa6af9
https://bugzilla.redhat.com/show_bug.cgi?id=1989441
fa6af9
---
fa6af9
 org_fedora_oscap/content_handling.py | 9 +++++----
fa6af9
 1 file changed, 5 insertions(+), 4 deletions(-)
fa6af9
fa6af9
diff --git a/org_fedora_oscap/content_handling.py b/org_fedora_oscap/content_handling.py
fa6af9
index f2af22f..65d5a28 100644
fa6af9
--- a/org_fedora_oscap/content_handling.py
fa6af9
+++ b/org_fedora_oscap/content_handling.py
fa6af9
@@ -111,9 +111,8 @@ def parse_HTML_from_content(content):
fa6af9
 
fa6af9
 
fa6af9
 def identify_files(fpaths):
fa6af9
-    with multiprocessing.Pool(os.cpu_count()) as p:
fa6af9
-        labels = p.map(get_doc_type, fpaths)
fa6af9
-    return {path: label for (path, label) in zip(fpaths, labels)}
fa6af9
+    result = {path: get_doc_type(path) for path in fpaths}
fa6af9
+    return result
fa6af9
 
fa6af9
 
fa6af9
 def get_doc_type(file_path):
fa6af9
@@ -131,7 +130,9 @@ def get_doc_type(file_path):
fa6af9
     except UnicodeDecodeError:
fa6af9
         # 'oscap info' supplied weird output, which happens when it tries
fa6af9
         # to explain why it can't examine e.g. a JPG.
fa6af9
-        return None
fa6af9
+        pass
fa6af9
+    except Exception as e:
fa6af9
+        log.warning(f"OSCAP addon: Unexpected error when looking at {file_path}: {str(e)}")
fa6af9
     log.info("OSCAP addon: Identified {file_path} as {content_type}"
fa6af9
              .format(file_path=file_path, content_type=content_type))
fa6af9
     return content_type