From 5c6f002878865f0b92c2de5327997dee079c96ec Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Mon, 28 Nov 2011 15:14:07 +0100 Subject: [PATCH] Silently pass when trying to kill child that is already dead. This fixes #16. --- rq/worker.py | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/rq/worker.py b/rq/worker.py index 92ba4e5..c78bd11 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -195,7 +195,13 @@ class Worker(object): # Take down the horse with the worker if self.horse_pid: self.log.debug('Taking down horse %d with me.' % self.horse_pid) - os.kill(self.horse_pid, signal.SIGKILL) + try: + os.kill(self.horse_pid, signal.SIGKILL) + except OSError as e: + # ESRCH ("No such process") is fine with us + if e.errno != errno.ESRCH: + self.log.debug('Horse already down.') + raise raise SystemExit() def request_stop(signum, frame):