From 2c0b578d653e7e33ce723bca446f5af466f287bd Mon Sep 17 00:00:00 2001 From: Charles Machalow Date: Tue, 17 Dec 2024 16:01:47 -0800 Subject: [PATCH] Apply suggestions from code review MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Co-authored-by: Bénédikt Tran <10796600+picnixz@users.noreply.github.com> --- Lib/concurrent/futures/process.py | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/Lib/concurrent/futures/process.py b/Lib/concurrent/futures/process.py index 50cc2a18d29875..9bbd71aaa515af 100644 --- a/Lib/concurrent/futures/process.py +++ b/Lib/concurrent/futures/process.py @@ -875,14 +875,14 @@ def terminate_workers(self, signal=signal.SIGTERM): for pid, proc in self._processes.items(): try: - is_alive = proc.is_alive() + if not proc.is_alive(): + continue except ValueError: # The process is already exited/closed out. - is_alive = False + continue - if is_alive: - try: - os.kill(pid, signal) - except ProcessLookupError: - # The process just ended before our signal - pass + try: + os.kill(pid, signal) + except ProcessLookupError: + # The process just ended before our signal + pass