Skip to contentSkip to conversation

sepolicy: generate man pages in parallel

PATCH Applied Ondrej Mosnacek 2 participants 2 messages Oct 18, 2019 – Oct 22, 2019 SELinux security module

lore
Share & tools
lore
#0 lore raw

PATCH v2 1/1 sepolicy: generate man pages in parallel

Generating man pages takes a lot of time. Do it in parallel to speed up the process.

---
 python/sepolicy/sepolicy.py | 14 +++++++++++---
 1 file changed, 11 insertions(+), 3 deletions(-)

Changes in v2:
- use multiprocessing.Pool, which reacts better to interruption

python/sepolicy/sepolicy.py +11 -3
index 1934cd86..7b223065 100755
@@ -25,6 +25,7 @@ import os
 import sys
 import selinux
 import sepolicy
+from multiprocessing import Pool
 from sepolicy import get_os_version, get_conditionals, get_conditionals_format_text
 import argparse
 PROGNAME = "policycoreutils"
@@ -326,8 +327,13 @@ def gen_gui_args(parser):
     gui.set_defaults(func=gui_run)
 
 
+def manpage_work(domain, path, root, source_files, web):
+    from sepolicy.manpage import ManPage
+    m = ManPage(domain, path, root, source_files, web)
+    print(m.get_man_page_path())
+
 def manpage(args):
-    from sepolicy.manpage import ManPage, HTMLManPages, manpage_domains, manpage_roles, gen_domains
+    from sepolicy.manpage import HTMLManPages, manpage_domains, manpage_roles, gen_domains
 
     path = args.path
     if not args.policy and args.root != "/":
@@ -340,9 +346,11 @@ def manpage(args):
     else:
         test_domains = args.domain
 
+    p = Pool()
     for domain in test_domains:
-        m = ManPage(domain, path, args.root, args.source_files, args.web)
-        print(m.get_man_page_path())
+        p.apply_async(manpage_work, [domain, path, args.root, args.source_files, args.web])
+    p.close()
+    p.join()
 
     if args.web:
         HTMLManPages(manpage_roles, manpage_domains, path, args.os)
Signature · 1 line
2.21.0
#1 lore raw
Quoted 4 lines · Ondrej Mosnacek

Generating man pages takes a lot of time. Do it in parallel to speed up the process.

Thanks, applied.

Quoted 49 lines
---
  python/sepolicy/sepolicy.py | 14 +++++++++++---
  1 file changed, 11 insertions(+), 3 deletions(-)

Changes in v2:
- use multiprocessing.Pool, which reacts better to interruption

python/sepolicy/sepolicy.py +11 -3
index 1934cd86..7b223065 100755
@@ -25,6 +25,7 @@ import os
  import sys
  import selinux
  import sepolicy
+from multiprocessing import Pool
  from sepolicy import get_os_version, get_conditionals, get_conditionals_format_text
  import argparse
  PROGNAME = "policycoreutils"
@@ -326,8 +327,13 @@ def gen_gui_args(parser):
      gui.set_defaults(func=gui_run)
 
 
+def manpage_work(domain, path, root, source_files, web):
+    from sepolicy.manpage import ManPage
+    m = ManPage(domain, path, root, source_files, web)
+    print(m.get_man_page_path())
+
  def manpage(args):
-    from sepolicy.manpage import ManPage, HTMLManPages, manpage_domains, manpage_roles, gen_domains
+    from sepolicy.manpage import HTMLManPages, manpage_domains, manpage_roles, gen_domains
 
      path = args.path
      if not args.policy and args.root != "/":
@@ -340,9 +346,11 @@ def manpage(args):
      else:
          test_domains = args.domain
 
+    p = Pool()
      for domain in test_domains:
-        m = ManPage(domain, path, args.root, args.source_files, args.web)
-        print(m.get_man_page_path())
+        p.apply_async(manpage_work, [domain, path, args.root, args.source_files, args.web])
+    p.close()
+    p.join()
 
      if args.web:
          HTMLManPages(manpage_roles, manpage_domains, path, args.os)