mirror of
https://github.com/sphinx-doc/sphinx.git
synced 2025-02-25 18:55:22 -06:00
Merge pull request #9793 from samdoran/enable-parallel-on-macos
Set multiprocessing start method to `fork`
This commit is contained in:
commit
4c7df3f09a
@ -12,7 +12,6 @@
|
|||||||
|
|
||||||
import os
|
import os
|
||||||
import pickle
|
import pickle
|
||||||
import platform
|
|
||||||
import sys
|
import sys
|
||||||
import warnings
|
import warnings
|
||||||
from collections import deque
|
from collections import deque
|
||||||
@ -195,12 +194,6 @@ class Sphinx:
|
|||||||
# say hello to the world
|
# say hello to the world
|
||||||
logger.info(bold(__('Running Sphinx v%s') % sphinx.__display_version__))
|
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
|
# status code for command-line application
|
||||||
self.statuscode = 0
|
self.statuscode = 0
|
||||||
|
|
||||||
|
@ -9,8 +9,6 @@
|
|||||||
"""
|
"""
|
||||||
|
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
import time
|
import time
|
||||||
import traceback
|
import traceback
|
||||||
from math import sqrt
|
from math import sqrt
|
||||||
@ -28,12 +26,7 @@ logger = logging.getLogger(__name__)
|
|||||||
|
|
||||||
|
|
||||||
# our parallel functionality only works for the forking Process
|
# our parallel functionality only works for the forking Process
|
||||||
#
|
parallel_available = multiprocessing and os.name == 'posix'
|
||||||
# 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'))
|
|
||||||
|
|
||||||
|
|
||||||
class SerialTasks:
|
class SerialTasks:
|
||||||
@ -64,7 +57,7 @@ class ParallelTasks:
|
|||||||
# task arguments
|
# task arguments
|
||||||
self._args: Dict[int, Optional[List[Any]]] = {}
|
self._args: Dict[int, Optional[List[Any]]] = {}
|
||||||
# list of subprocesses (both started and waiting)
|
# 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
|
# list of receiving pipe connections of running subprocesses
|
||||||
self._precvs: Dict[int, Any] = {}
|
self._precvs: Dict[int, Any] = {}
|
||||||
# list of receiving pipe connections of waiting subprocesses
|
# 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._result_funcs[tid] = result_func or (lambda arg, result: None)
|
||||||
self._args[tid] = arg
|
self._args[tid] = arg
|
||||||
precv, psend = multiprocessing.Pipe(False)
|
precv, psend = multiprocessing.Pipe(False)
|
||||||
proc = multiprocessing.Process(target=self._process,
|
context = multiprocessing.get_context('fork')
|
||||||
args=(psend, task_func, arg))
|
proc = context.Process(target=self._process, args=(psend, task_func, arg))
|
||||||
self._procs[tid] = proc
|
self._procs[tid] = proc
|
||||||
self._precvsWaiting[tid] = precv
|
self._precvsWaiting[tid] = precv
|
||||||
self._join_one()
|
self._join_one()
|
||||||
|
@ -10,8 +10,6 @@
|
|||||||
|
|
||||||
import codecs
|
import codecs
|
||||||
import os
|
import os
|
||||||
import platform
|
|
||||||
import sys
|
|
||||||
|
|
||||||
import pytest
|
import pytest
|
||||||
from docutils import nodes
|
from docutils import nodes
|
||||||
@ -318,8 +316,6 @@ def test_colored_logs(app, status, warning):
|
|||||||
|
|
||||||
|
|
||||||
@pytest.mark.xfail(os.name != 'posix', reason="Not working on windows")
|
@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):
|
def test_logging_in_ParallelTasks(app, status, warning):
|
||||||
logging.setup(app, status, warning)
|
logging.setup(app, status, warning)
|
||||||
logger = logging.getLogger(__name__)
|
logger = logging.getLogger(__name__)
|
||||||
|
Loading…
Reference in New Issue
Block a user