[arch-commits] Commit in sagemath-doc/trunk (sagemath-doc-segfault.patch)

Antonio Rojas arojas at archlinux.org
Wed Dec 5 16:51:54 UTC 2018


    Date: Wednesday, December 5, 2018 @ 16:51:53
  Author: arojas
Revision: 411558

Add missing patch

Added:
  sagemath-doc/trunk/sagemath-doc-segfault.patch

-----------------------------+
 sagemath-doc-segfault.patch |   63 ++++++++++++++++++++++++++++++++++++++++++
 1 file changed, 63 insertions(+)

Added: sagemath-doc-segfault.patch
===================================================================
--- sagemath-doc-segfault.patch	                        (rev 0)
+++ sagemath-doc-segfault.patch	2018-12-05 16:51:53 UTC (rev 411558)
@@ -0,0 +1,63 @@
+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
+index 5877b5b..7dc8ff7 100644
+--- a/src/sage_setup/docbuild/__init__.py
++++ b/src/sage_setup/docbuild/__init__.py
+@@ -265,35 +265,29 @@ class DocBuilder(object):
+     # import the customized builder for object.inv files
+     inventory = builder_helper('inventory')
+ 
+-if NUM_THREADS > 1:
+-    def build_many(target, args):
+-        from multiprocessing import Pool
+-        pool = Pool(NUM_THREADS, maxtasksperchild=1)
+-        # map_async handles KeyboardInterrupt correctly. Plain map and
+-        # apply_async does not, so don't use it.
+-        x = pool.map_async(target, args, 1)
+-        try:
+-            ret = x.get(99999)
+-            pool.close()
+-            pool.join()
+-        except Exception:
+-            pool.terminate()
+-            if ABORT_ON_ERROR:
+-                raise
+-        return ret
+-else:
+-    def build_many(target, args):
+-        results = []
+-
+-        for arg in args:
+-            try:
+-                results.append(target(arg))
+-            except Exception:
+-                if ABORT_ON_ERROR:
+-                    raise
+-
+-        return results
+-
++def build_many(target, args):
++    # Pool() uses an actual fork() to run each new instance. This is important
++    # for performance reasons, i.e., don't use a forkserver when it becomes
++    # available with Python 3: Here, sage is already initialized which is quite
++    # costly, with a forkserver we would have to reinitialize it for every
++    # document we build. At the same time, don't serialize this by taking the
++    # pool (and thus the call to fork()) out completely: The call to Sphinx
++    # leaks memory, so we need to build each document in its own process to
++    # control the RAM usage.
++    from multiprocessing import Pool
++    pool = Pool(NUM_THREADS, maxtasksperchild=1)
++    # map_async handles KeyboardInterrupt correctly. Plain map and
++    # apply_async does not, so don't use it.
++    x = pool.map_async(target, args, 1)
++    try:
++        ret = x.get(99999)
++        pool.close()
++        pool.join()
++    except Exception:
++        pool.terminate()
++        if ABORT_ON_ERROR:
++            raise
++    return ret
+ 
+ ##########################################
+ #      Parallel Building Ref Manual      #


More information about the arch-commits mailing list