@@ -0,0 +1,71 @@
1+commit f1c59929c3c180ac283334c2b3c901ac8c82f6b1
2+Author: Timo Kaufmann <timokau@zoho.com>
3+Date: Sat Oct 20 20:07:41 2018 +0200
4+
5+ Revert "Something related to the sphinxbuild seems to be leaking memory"
6+
7+ This reverts commit 7d85dc796c58c3de57401bc22d3587b94e205091.
8+
9+diff --git a/src/sage_setup/docbuild/__init__.py b/src/sage_setup/docbuild/__init__.py
10+index 0b24b1a60b..084c3f89d7 100644
11+--- a/src/sage_setup/docbuild/__init__.py
12++++ b/src/sage_setup/docbuild/__init__.py
13+@@ -265,29 +265,35 @@ class DocBuilder(object):
14+ # import the customized builder for object.inv files
15+ inventory = builder_helper('inventory')
16+
17+-def build_many(target, args):
18+- # Pool() uses an actual fork() to run each new instance. This is important
19+- # for performance reasons, i.e., don't use a forkserver when it becomes
20+- # available with Python 3: Here, sage is already initialized which is quite
21+- # costly, with a forkserver we would have to reinitialize it for every
22+- # document we build. At the same time, don't serialize this by taking the
23+- # pool (and thus the call to fork()) out completely: The call to Sphinx
24+- # leaks memory, so we need to build each document in its own process to
25+- # control the RAM usage.
26+- from multiprocessing import Pool
27+- pool = Pool(NUM_THREADS, maxtasksperchild=1)
28+- # map_async handles KeyboardInterrupt correctly. Plain map and
29+- # apply_async does not, so don't use it.
30+- x = pool.map_async(target, args, 1)
31+- try:
32+- ret = x.get(99999)
33+- pool.close()
34+- pool.join()
35+- except Exception:
36+- pool.terminate()
37+- if ABORT_ON_ERROR:
38+- raise
39+- return ret
40++if NUM_THREADS > 1:
41++ def build_many(target, args):
42++ from multiprocessing import Pool
43++ pool = Pool(NUM_THREADS, maxtasksperchild=1)
44++ # map_async handles KeyboardInterrupt correctly. Plain map and
45++ # apply_async does not, so don't use it.
46++ x = pool.map_async(target, args, 1)
47++ try:
48++ ret = x.get(99999)
49++ pool.close()
50++ pool.join()
51++ except Exception:
52++ pool.terminate()
53++ if ABORT_ON_ERROR:
54++ raise
55++ return ret
56++else:
57++ def build_many(target, args):
58++ results = []
59++
60++ for arg in args:
61++ try:
62++ results.append(target(arg))
63++ except Exception:
64++ if ABORT_ON_ERROR:
65++ raise
66++
67++ return results
68++
69+
70+ ##########################################
71+ # Parallel Building Ref Manual #