From b5b658da0683c3e0806461946d8b492784e26d97 Mon Sep 17 00:00:00 2001 From: Zsolt Dollenstein Date: Sat, 21 Apr 2018 20:16:02 +0100 Subject: [PATCH] Skip handling signals on event loops that don't support it (#156) --- black.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/black.py b/black.py index 49a5729..9dd3536 100644 --- a/black.py +++ b/black.py @@ -293,8 +293,12 @@ async def schedule_formatting( for src in sources } _task_values = list(tasks.values()) - loop.add_signal_handler(signal.SIGINT, cancel, _task_values) - loop.add_signal_handler(signal.SIGTERM, cancel, _task_values) + try: + loop.add_signal_handler(signal.SIGINT, cancel, _task_values) + loop.add_signal_handler(signal.SIGTERM, cancel, _task_values) + except NotImplementedError: + # There are no good alternatives for these on Windows + pass await asyncio.wait(_task_values) for src, task in tasks.items(): if not task.done(): -- 2.39.5