Skip to content

Commit 3bf5464

Browse files
committed
Swap to SIGTERM as the default
1 parent 61c9b14 commit 3bf5464

File tree

1 file changed

+17
-15
lines changed

1 file changed

+17
-15
lines changed

Lib/concurrent/futures/process.py

Lines changed: 17 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -857,7 +857,7 @@ def shutdown(self, wait=True, *, cancel_futures=False):
857857

858858
shutdown.__doc__ = _base.Executor.shutdown.__doc__
859859

860-
def terminate_workers(self, signal=signal.SIGINT):
860+
def terminate_workers(self, signal=signal.SIGTERM):
861861
"""Attempts to terminate the executor's workers using the given signal.
862862
Iterates through all of the current processes and sends the given signal if
863863
the process is still alive.
@@ -866,19 +866,21 @@ def terminate_workers(self, signal=signal.SIGINT):
866866
867867
Args:
868868
signal: The signal to send to each worker process. Defaults to
869-
signal.SIGINT.
869+
signal.SIGTERM.
870870
"""
871-
if self._processes:
872-
for pid, proc in self._processes.items():
873-
try:
874-
is_alive = proc.is_alive()
875-
except ValueError:
876-
# The process is already exited/closed out.
877-
is_alive = False
871+
if not self._processes:
872+
return
878873

879-
if is_alive:
880-
try:
881-
os.kill(pid, signal)
882-
except ProcessLookupError:
883-
# The process just ended before our signal
884-
pass
874+
for pid, proc in self._processes.items():
875+
try:
876+
is_alive = proc.is_alive()
877+
except ValueError:
878+
# The process is already exited/closed out.
879+
is_alive = False
880+
881+
if is_alive:
882+
try:
883+
os.kill(pid, signal)
884+
except ProcessLookupError:
885+
# The process just ended before our signal
886+
pass

0 commit comments

Comments
 (0)