diff --git a/docs/changelog.rst b/docs/changelog.rst index 7e917d7b9..182070e09 100644 --- a/docs/changelog.rst +++ b/docs/changelog.rst @@ -4,6 +4,12 @@ Changelog |kitty| is a feature full, cross-platform, *fast*, GPU based terminal emulator. To update |kitty|, :doc:`follow the instructions `. +0.18.1 [future] +-------------------- + +- macOS: Fix for diff kitten not working with python 3.8 (:iss:`2780`) + + 0.18.0 [2020-06-20] -------------------- diff --git a/kittens/diff/highlight.py b/kittens/diff/highlight.py index d8933b639..376d5965c 100644 --- a/kittens/diff/highlight.py +++ b/kittens/diff/highlight.py @@ -5,6 +5,8 @@ import concurrent import os import re +import sys +from multiprocessing import get_context from typing import IO, Dict, Iterable, List, Optional, Tuple, Union, cast from pygments import highlight # type: ignore @@ -139,7 +141,14 @@ def highlight_for_diff(path: str, aliases: Dict[str, str]) -> DiffHighlight: def highlight_collection(collection: Collection, aliases: Optional[Dict[str, str]] = None) -> Union[str, Dict[str, DiffHighlight]]: jobs = {} ans: Dict[str, DiffHighlight] = {} - with concurrent.futures.ProcessPoolExecutor(max_workers=os.cpu_count()) as executor: + if sys.version_info[:2] >= (3, 7): + # On macOS as of python 3.8 the default executor is changed to spawn + # which causes failures, so use fork, which is also faster + ppe = concurrent.futures.ProcessPoolExecutor(mp_context=get_context('fork')) + else: + ppe = concurrent.futures.ProcessPoolExecutor() + + with ppe as executor: for path, item_type, other_path in collection: if item_type != 'rename': for p in (path, other_path):