forked from M-Labs/artiq
1
0
Fork 0

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: except:
logger.warning("Controller %s did not respond to terminate " logger.warning("Controller %s did not respond to terminate "
"command, killing", self.name) "command, killing", self.name)
try:
self.process.kill() self.process.kill()
except ProcessLookupError:
pass
try: try:
await asyncio.wait_for(self.process.wait(), await asyncio.wait_for(self.process.wait(),
self.term_timeout) self.term_timeout)
except: except:
logger.warning("Controller %s failed to exit, killing", logger.warning("Controller %s failed to exit, killing",
self.name) self.name)
try:
self.process.kill() self.process.kill()
except ProcessLookupError:
pass
await self.process.wait() await self.process.wait()
logger.debug("Controller %s terminated", self.name) logger.debug("Controller %s terminated", self.name)

View File

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