From 6d41640ea979ee03b66e73d14dec9730b44328ff Mon Sep 17 00:00:00 2001 From: Lev Kokotov Date: Wed, 7 Sep 2022 09:22:52 -0700 Subject: [PATCH] Send signal even if process is gone (#162) * Send signal even if process is gone * hmm * hmm --- tests/python/tests.py | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/tests/python/tests.py b/tests/python/tests.py index 092fc8c..7c99079 100644 --- a/tests/python/tests.py +++ b/tests/python/tests.py @@ -18,9 +18,14 @@ def pgcat_start(): def pg_cat_send_signal(signal: signal.Signals): - for proc in psutil.process_iter(["pid", "name"]): - if "pgcat" == proc.name(): - os.kill(proc.pid, signal) + try: + for proc in psutil.process_iter(["pid", "name"]): + if "pgcat" == proc.name(): + os.kill(proc.pid, signal) + except Exception as e: + # The process can be gone when we send this signal + print(e) + if signal == signal.SIGTERM: # Returns 0 if pgcat process exists time.sleep(2)