ignore ProcessLookupError when killing subprocesses. Closes #167

This commit is contained in:
Sebastien Bourdeauducq 2015-10-28 20:57:28 +08:00
parent 40b4129c65
commit 0d53f7ab0d
2 changed files with 16 additions and 4 deletions

View File

@ -134,14 +134,20 @@ class Controller:
except:
logger.warning("Controller %s did not respond to terminate "
"command, killing", self.name)
self.process.kill()
try:
self.process.kill()
except ProcessLookupError:
pass
try:
await asyncio.wait_for(self.process.wait(),
self.term_timeout)
except:
logger.warning("Controller %s failed to exit, killing",
self.name)
self.process.kill()
try:
self.process.kill()
except ProcessLookupError:
pass
await self.process.wait()
logger.debug("Controller %s terminated", self.name)

View File

@ -94,14 +94,20 @@ class Worker:
except:
logger.warning("failed to send terminate command to worker"
" (RID %s), killing", self.rid, exc_info=True)
self.process.kill()
try:
self.process.kill()
except ProcessLookupError:
pass
await self.process.wait()
return
try:
await asyncio.wait_for(self.process.wait(), term_timeout)
except asyncio.TimeoutError:
logger.warning("worker did not exit (RID %s), killing", self.rid)
self.process.kill()
try:
self.process.kill()
except ProcessLookupError:
pass
await self.process.wait()
else:
logger.debug("worker exited gracefully (RID %s)", self.rid)