Skip to content

Commit 62d74a2

Browse files
authored
Merge pull request #1723 from rhatdan/kills
If container fails on Run, warn and exit
2 parents fbec474 + e93fb5a commit 62d74a2

File tree

1 file changed

+8
-2
lines changed

1 file changed

+8
-2
lines changed

ramalama/chat.py

Lines changed: 8 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
#!/usr/bin/env python3
22

33
import cmd
4+
import copy
45
import itertools
56
import json
67
import os
@@ -212,7 +213,9 @@ def kills(self):
212213
os.kill(self.args.pid2kill, signal.SIGTERM)
213214
os.kill(self.args.pid2kill, signal.SIGKILL)
214215
elif getattr(self.args, "name", None):
215-
stop_container(self.args, self.args.name)
216+
args = copy.copy(self.args)
217+
args.ignore = True
218+
stop_container(args, self.args.name)
216219

217220
def loop(self):
218221
while True:
@@ -275,7 +278,10 @@ def chat(args: ChatArgsType, operational_args: ChatOperationalArgs = ChatOperati
275278
finally:
276279
# Reset the alarm to 0 to cancel any pending alarms
277280
signal.alarm(0)
278-
shell.kills()
281+
try:
282+
shell.kills()
283+
except Exception as e:
284+
logger.warning(f"Failed to clean up resources: {e}")
279285

280286

281287
UNITS = {"s": "seconds", "m": "minutes", "h": "hours", "d": "days", "w": "weeks"}

0 commit comments

Comments
 (0)