From b611b6473776bba1c55878a0996e9e1e60118331 Mon Sep 17 00:00:00 2001 From: Cooper Ry Lees Date: Wed, 13 Jul 2022 05:00:20 +0000 Subject: [PATCH] Move to explicitly creating a new loop MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit - >= 3.10 add a warning that `get_event_loop` will not automatically create a loop - Move to explicit API Test: - `python3.11 -m venv --upgrade-deps /tmp/tb` - `/tmp/tb/bin/pip install -e .` - Install deps and no blackd as aiohttp + yarl can't build still with 3.11 - https://github.com/aio-libs/aiohttp/issues/6600 - `export PYTHONWARNINGS=error` ``` cooper@l33t:~/repos/black$ /tmp/tb/bin/black . All done! ✨ 🍰 ✨ 44 files left unchanged. ``` Fixes #3110 --- src/black/__init__.py | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/src/black/__init__.py b/src/black/__init__.py index 2d04cf81910..4ad69acd01f 100644 --- a/src/black/__init__.py +++ b/src/black/__init__.py @@ -773,7 +773,6 @@ def reformat_many( from concurrent.futures import Executor, ThreadPoolExecutor, ProcessPoolExecutor executor: Executor - loop = asyncio.get_event_loop() worker_count = workers if workers is not None else DEFAULT_WORKERS if sys.platform == "win32": # Work around https://bugs.python.org/issue26903 @@ -788,6 +787,7 @@ def reformat_many( # any good due to the Global Interpreter Lock) executor = ThreadPoolExecutor(max_workers=1) + loop = asyncio.new_event_loop() try: loop.run_until_complete( schedule_formatting(