From 1177caf4bf5dabbf9dc066b42a55aefec556ca24 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Sun, 5 Aug 2012 09:42:27 +0200 Subject: [PATCH] Set state to busy as early as possible. --- rq/worker.py | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/rq/worker.py b/rq/worker.py index 1e7ea0d..897c66c 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -253,10 +253,10 @@ class Worker(object): # before shutting down if self.state == 'busy': self._stopped = True - self.log.debug('Stopping after current horse is finished.' + self.log.debug('Stopping after current horse is finished. ' 'Press Ctrl+C again for a cold shutdown.') else: - raise StopRequested + raise StopRequested() signal.signal(signal.SIGINT, request_stop) signal.signal(signal.SIGTERM, request_stop) @@ -306,11 +306,12 @@ class Worker(object): self.failed_queue.push_job_id(e.job_id) continue + self.state = 'busy' + job, queue = result self.log.info('%s: %s (%s)' % (green(queue.name), blue(job.description), job.id)) - self.state = 'busy' self.fork_and_perform_job(job) did_perform_work = True