From 1c0ff3a12186ae54a419837acd10bef47f6ba574 Mon Sep 17 00:00:00 2001 From: l_samenv Date: Fri, 25 Aug 2023 16:58:53 +0200 Subject: [PATCH 1/2] do not crash when process is already killed in the mean time --- base.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/base.py b/base.py index ead47e4..1d8d846 100644 --- a/base.py +++ b/base.py @@ -237,7 +237,10 @@ class ServiceManager: for p in procs.get(ins, {}).get(service, []): print_wait = True for action in ('terminate', 'kill'): - getattr(p, action)() # p.terminate or p.kill + try: + getattr(p, action)() # p.terminate or p.kill + except psutil.NoSuchProcess: + continue # already killed for i in range(10): # total 0.1 * 10 * 9 / 2 = 4.5 sec try: p.wait(0.1 * i) From b4d41a297d3f1cc6fb5b1e5961175df6e71e46cd Mon Sep 17 00:00:00 2001 From: l_samenv Date: Fri, 25 Aug 2023 21:07:25 +0200 Subject: [PATCH 2/2] do not accept stop without instrument or 'all' --- base.py | 2 ++ 1 file changed, 2 insertions(+) diff --git a/base.py b/base.py index 1d8d846..0ed20cd 100644 --- a/base.py +++ b/base.py @@ -264,6 +264,8 @@ class ServiceManager: def do_stop(self, ins, service=None, *args): self.get_info() + if ins is None: + raise ValueError('use stop all if you really want to stop all') ins_list = self.wildcard(ins) if ins_list is not None: return ins_list