From fe24a15b84955130f23c8ab9490d1cdb98607b53 Mon Sep 17 00:00:00 2001 From: Peter Stensmyr Date: Sat, 15 Dec 2018 02:01:50 +1100 Subject: [PATCH] Fix multiprocessing support for Windows binary (#632) * Fix multiprocessing support for Windows binary The black and blackd binaries generated for Windows builds would fail on reformatting multiple files due to a Windows-specific multiprocessing issue. Fix by calling freeze_support() as described in Python docs. --- black.py | 3 ++- blackd.py | 2 ++ 2 files changed, 4 insertions(+), 1 deletion(-) diff --git a/black.py b/black.py index c1cc080..8855c37 100644 --- a/black.py +++ b/black.py @@ -8,7 +8,7 @@ import io import itertools import keyword import logging -from multiprocessing import Manager +from multiprocessing import Manager, freeze_support import os from pathlib import Path import pickle @@ -3658,6 +3658,7 @@ def patch_click() -> None: def patched_main() -> None: + freeze_support() patch_click() main() diff --git a/blackd.py b/blackd.py index c5aa29c..1a3b369 100644 --- a/blackd.py +++ b/blackd.py @@ -2,6 +2,7 @@ import asyncio from concurrent.futures import Executor, ProcessPoolExecutor from functools import partial import logging +from multiprocessing import freeze_support from aiohttp import web import aiohttp_cors @@ -130,6 +131,7 @@ async def handle(request: web.Request, executor: Executor) -> web.Response: def patched_main() -> None: + freeze_support() black.patch_click() main() -- 2.39.5