Handle process disappearing before we ask for its PPID

Change-Id: I573aba8e11dca16f8a6565f7e9704be18e938566
Closes-Bug: #1478190
This commit is contained in:
Neil Jerram 2015-09-06 01:09:16 +01:00
parent 64c596a6c1
commit 42f80682d3
1 changed files with 7 additions and 1 deletions

View File

@ -105,9 +105,15 @@ class TestNeutronServer(base.BaseTestCase):
def _get_workers(self):
"""Get the list of processes in which WSGI server is running."""
def safe_ppid(proc):
try:
return proc.ppid
except psutil.NoSuchProcess:
return None
if self.workers > 0:
return [proc.pid for proc in psutil.process_iter()
if proc.ppid == self.service_pid]
if safe_ppid(proc) == self.service_pid]
else:
return [proc.pid for proc in psutil.process_iter()
if proc.pid == self.service_pid]