Skip to content

Commit

Permalink
Merge pull request #6879 from tk0miya/6803_parallel_build_error_on_macOS
Browse files Browse the repository at this point in the history
Fix #6803: Disable parallel build on macOS and py38+
  • Loading branch information
tk0miya authored Dec 1, 2019
2 parents dc53404 + e742af0 commit 3bc16b0
Show file tree
Hide file tree
Showing 6 changed files with 25 additions and 3 deletions.
4 changes: 4 additions & 0 deletions CHANGES
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,9 @@ Dependencies
Incompatible changes
--------------------

* #6803: For security reason of python, parallel mode is disabled on macOS and
Python3.8+

Deprecated
----------

Expand All @@ -19,6 +22,7 @@ Bugs fixed
* #6776: LaTeX: 2019-10-01 LaTeX release breaks :file:`sphinxcyrillic.sty`
* #6815: i18n: French, Hindi, Japanese and Korean translation messages has been
broken
* #6803: parallel build causes AttributeError on macOS and Python3.8

Testing
--------
Expand Down
2 changes: 1 addition & 1 deletion setup.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,7 @@
'html5lib',
'flake8>=3.5.0',
'flake8-import-order',
'mypy>=0.740',
'mypy>=0.750',
'docutils-stubs',
],
}
Expand Down
7 changes: 7 additions & 0 deletions sphinx/application.py
Original file line number Diff line number Diff line change
Expand Up @@ -12,6 +12,7 @@

import os
import pickle
import platform
import sys
import warnings
from collections import deque
Expand Down Expand Up @@ -199,6 +200,12 @@ def __init__(self, srcdir, confdir, outdir, doctreedir, buildername,
# 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 reason, 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

Expand Down
2 changes: 1 addition & 1 deletion sphinx/pycode/parser.py
Original file line number Diff line number Diff line change
Expand Up @@ -129,7 +129,7 @@ class TokenProcessor:
def __init__(self, buffers: List[str]) -> None:
lines = iter(buffers)
self.buffers = buffers
self.tokens = tokenize.generate_tokens(lambda: next(lines))
self.tokens = tokenize.generate_tokens(lambda: next(lines)) # type: ignore
self.current = None # type: Token
self.previous = None # type: Token

Expand Down
9 changes: 8 additions & 1 deletion sphinx/util/parallel.py
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,8 @@
"""

import os
import platform
import sys
import time
import traceback
from math import sqrt
Expand All @@ -26,7 +28,12 @@


# 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:
Expand Down
4 changes: 4 additions & 0 deletions tests/test_util_logging.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,8 @@

import codecs
import os
import platform
import sys

import pytest
from docutils import nodes
Expand Down Expand Up @@ -276,6 +278,8 @@ 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__)
Expand Down

0 comments on commit 3bc16b0

Please sign in to comment.