mirror of
https://github.com/postgresml/pgcat.git
synced 2026-03-26 18:36:28 +00:00
Send signal even if process is gone (#162)
* Send signal even if process is gone * hmm * hmm
This commit is contained in:
@@ -18,9 +18,14 @@ def pgcat_start():
|
|||||||
|
|
||||||
|
|
||||||
def pg_cat_send_signal(signal: signal.Signals):
|
def pg_cat_send_signal(signal: signal.Signals):
|
||||||
for proc in psutil.process_iter(["pid", "name"]):
|
try:
|
||||||
if "pgcat" == proc.name():
|
for proc in psutil.process_iter(["pid", "name"]):
|
||||||
os.kill(proc.pid, signal)
|
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:
|
if signal == signal.SIGTERM:
|
||||||
# Returns 0 if pgcat process exists
|
# Returns 0 if pgcat process exists
|
||||||
time.sleep(2)
|
time.sleep(2)
|
||||||
|
|||||||
Reference in New Issue
Block a user