Skip to content

Commit 7612a6e

Browse files
committed
podman: also terminate any lingering containers
1 parent e9c4a00 commit 7612a6e

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

cwltool/main.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -106,6 +106,8 @@
106106
)
107107
from .workflow import Workflow
108108

109+
docker_exe: str
110+
109111

110112
def _terminate_processes() -> None:
111113
"""Kill all spawned processes.
@@ -118,6 +120,7 @@ def _terminate_processes() -> None:
118120
continuing to execute while it kills the processes that they've
119121
spawned. This may occasionally lead to unexpected behaviour.
120122
"""
123+
global docker_exe
121124
# It's possible that another thread will spawn a new task while
122125
# we're executing, so it's not safe to use a for loop here.
123126
while processes_to_kill:
@@ -131,7 +134,7 @@ def _terminate_processes() -> None:
131134
try:
132135
with open(cidfile[0]) as inp_stream:
133136
p = subprocess.Popen( # nosec
134-
["docker", "kill", inp_stream.read()], shell=False # nosec
137+
[docker_exe, "kill", inp_stream.read()], shell=False # nosec
135138
)
136139
try:
137140
p.wait(timeout=10)
@@ -1010,6 +1013,7 @@ def main(
10101013
stderr_handler = _logger.handlers[-1]
10111014
workflowobj = None
10121015
prov_log_handler: Optional[logging.StreamHandler[ProvOut]] = None
1016+
global docker_exe
10131017
try:
10141018
if args is None:
10151019
if argsl is None:
@@ -1031,6 +1035,10 @@ def main(
10311035
else:
10321036
runtimeContext = runtimeContext.copy()
10331037

1038+
if runtimeContext.podman:
1039+
docker_exe = "podman"
1040+
else:
1041+
docker_exe = "docker"
10341042
# If caller parsed its own arguments, it may not include every
10351043
# cwltool option, so fill in defaults to avoid crashing when
10361044
# dereferencing them in args.

0 commit comments

Comments
 (0)