summaryrefslogtreecommitdiff
path: root/sphinx/util/parallel.py
diff options
context:
space:
mode:
authorSam Doran <sdoran@redhat.com>2021-10-28 12:38:56 -0400
committerSam Doran <sdoran@redhat.com>2021-10-28 12:38:56 -0400
commit83225767cbe41294b97c63e34efe455fd2a9338d (patch)
treeefd89f4d556dd0a9ca46dc2eae3ba373053ded12 /sphinx/util/parallel.py
parent4c91c038b220d07bbdfe0c1680af42fe897f342c (diff)
downloadsphinx-git-83225767cbe41294b97c63e34efe455fd2a9338d.tar.gz
Set multiprocessing start method to fork
Since the current code requires forking, set it explicitly rather than disabling parallelization on macOS.
Diffstat (limited to 'sphinx/util/parallel.py')
-rw-r--r--sphinx/util/parallel.py15
1 files changed, 4 insertions, 11 deletions
diff --git a/sphinx/util/parallel.py b/sphinx/util/parallel.py
index 2a83d6297..d7abc81df 100644
--- a/sphinx/util/parallel.py
+++ b/sphinx/util/parallel.py
@@ -9,8 +9,6 @@
"""
import os
-import platform
-import sys
import time
import traceback
from math import sqrt
@@ -28,12 +26,7 @@ logger = logging.getLogger(__name__)
# our parallel functionality only works for the forking Process
-#
-# Note: "fork" is not recommended on macOS and py38+.
-# see https://bugs.python.org/issue33725
-parallel_available = (multiprocessing and
- (os.name == 'posix') and
- not (sys.version_info > (3, 8) and platform.system() == 'Darwin'))
+parallel_available = multiprocessing and os.name == 'posix'
class SerialTasks:
@@ -64,7 +57,7 @@ class ParallelTasks:
# task arguments
self._args: Dict[int, Optional[List[Any]]] = {}
# list of subprocesses (both started and waiting)
- self._procs: Dict[int, multiprocessing.Process] = {}
+ self._procs: Dict[int, multiprocessing.context.ForkProcess] = {}
# list of receiving pipe connections of running subprocesses
self._precvs: Dict[int, Any] = {}
# list of receiving pipe connections of waiting subprocesses
@@ -96,8 +89,8 @@ class ParallelTasks:
self._result_funcs[tid] = result_func or (lambda arg, result: None)
self._args[tid] = arg
precv, psend = multiprocessing.Pipe(False)
- proc = multiprocessing.Process(target=self._process,
- args=(psend, task_func, arg))
+ context = multiprocessing.get_context('fork')
+ proc = context.Process(target=self._process, args=(psend, task_func, arg))
self._procs[tid] = proc
self._precvsWaiting[tid] = precv
self._join_one()