macOS: Fix for diff kitten not working with python 3.8

Fixes #2780
This commit is contained in:
Kovid Goyal 2020-06-20 19:03:45 +05:30
parent f62e2374e4
commit e07916425e
No known key found for this signature in database
GPG Key ID: 06BC317B515ACE7C
2 changed files with 16 additions and 1 deletions

View File

@ -4,6 +4,12 @@ Changelog
|kitty| is a feature full, cross-platform, *fast*, GPU based terminal emulator. |kitty| is a feature full, cross-platform, *fast*, GPU based terminal emulator.
To update |kitty|, :doc:`follow the instructions <binary>`. To update |kitty|, :doc:`follow the instructions <binary>`.
0.18.1 [future]
--------------------
- macOS: Fix for diff kitten not working with python 3.8 (:iss:`2780`)
0.18.0 [2020-06-20] 0.18.0 [2020-06-20]
-------------------- --------------------

View File

@ -5,6 +5,8 @@
import concurrent import concurrent
import os import os
import re import re
import sys
from multiprocessing import get_context
from typing import IO, Dict, Iterable, List, Optional, Tuple, Union, cast from typing import IO, Dict, Iterable, List, Optional, Tuple, Union, cast
from pygments import highlight # type: ignore 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]]: def highlight_collection(collection: Collection, aliases: Optional[Dict[str, str]] = None) -> Union[str, Dict[str, DiffHighlight]]:
jobs = {} jobs = {}
ans: Dict[str, DiffHighlight] = {} 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: for path, item_type, other_path in collection:
if item_type != 'rename': if item_type != 'rename':
for p in (path, other_path): for p in (path, other_path):