Skip to content

Commit 87c0cb0

Browse files
author
ekultek
committed
caught an exception that happens from psutils
1 parent b5b2b2a commit 87c0cb0

1 file changed

Lines changed: 16 additions & 8 deletions

File tree

lib/settings.py

Lines changed: 16 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -85,14 +85,22 @@ def check_services(service_name):
8585
"""
8686
check to see if certain services ar started
8787
"""
88-
all_processes = set()
89-
for pid in psutil.pids():
90-
running_proc = psutil.Process(pid)
91-
all_processes.add(" ".join(running_proc.cmdline()).strip())
92-
for proc in list(all_processes):
93-
if service_name in proc:
94-
return True
95-
return False
88+
try:
89+
all_processes = set()
90+
for pid in psutil.pids():
91+
running_proc = psutil.Process(pid)
92+
all_processes.add(" ".join(running_proc.cmdline()).strip())
93+
for proc in list(all_processes):
94+
if service_name in proc:
95+
return True
96+
return False
97+
except psutil.ZombieProcess as e:
98+
# zombie processes appear to happen on macOS for some reason
99+
# so we'll just kill them off
100+
pid = str(e).split("=")[-1].split(")")[0]
101+
os.kill(int(pid), 0)
102+
return True
103+
96104

97105

98106
def write_to_file(data_to_write, filename, mode="a+"):

0 commit comments

Comments
 (0)