Send signal even if process is gone (#162)

* Send signal even if process is gone

* hmm

* hmm
This commit is contained in:
Lev Kokotov
2022-09-07 09:22:52 -07:00
committed by GitHub
parent 744ceada86
commit 6d41640ea9

View File

@@ -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)