mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Set multiprocessing start method to fork
Since the current code requires forking, set it explicitly rather than disabling parallelization on macOS.
This commit is contained in:
parent
4c91c038b2
commit
83225767cb
@ -12,7 +12,6 @@
|
||||
|
||||
import os
|
||||
import pickle
|
||||
import platform
|
||||
import sys
|
||||
import warnings
|
||||
from collections import deque
|
||||
@ -195,12 +194,6 @@ class Sphinx:
|
||||
# say hello to the world
|
||||
logger.info(bold(__('Running Sphinx v%s') % sphinx.__display_version__))
|
||||
|
||||
# notice for parallel build on macOS and py38+
|
||||
if sys.version_info > (3, 8) and platform.system() == 'Darwin' and parallel > 1:
|
||||
logger.info(bold(__("For security reasons, parallel mode is disabled on macOS and "
|
||||
"python3.8 and above. For more details, please read "
|
||||
"https://github.com/sphinx-doc/sphinx/issues/6803")))
|
||||
|
||||
# status code for command-line application
|
||||
self.statuscode = 0
|
||||
|
||||
|
@ -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()
|
||||
|
@ -10,8 +10,6 @@
|
||||
|
||||
import codecs
|
||||
import os
|
||||
import platform
|
||||
import sys
|
||||
|
||||
import pytest
|
||||
from docutils import nodes
|
||||
@ -311,8 +309,6 @@ def test_colored_logs(app, status, warning):
|
||||
|
||||
|
||||
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
|
||||
@pytest.mark.xfail(platform.system() == 'Darwin' and sys.version_info > (3, 8),
|
||||
reason="Not working on macOS and py38")
|
||||
def test_logging_in_ParallelTasks(app, status, warning):
|
||||
logging.setup(app, status, warning)
|
||||
logger = logging.getLogger(__name__)
|
||||
|
Loading…
Reference in New Issue
Block a user