From 8787cfbb303f529e0f34ed6fa97c08b68d82065c Mon Sep 17 00:00:00 2001 From: Timo Steidle Date: Thu, 6 Sep 2012 14:56:19 +0200 Subject: [PATCH] Added new job status "Running" --- rq/job.py | 7 ++++++- rq/worker.py | 2 ++ 2 files changed, 8 insertions(+), 1 deletion(-) diff --git a/rq/job.py b/rq/job.py index a417cc4..c14733e 100644 --- a/rq/job.py +++ b/rq/job.py @@ -13,7 +13,8 @@ def enum(name, *sequential, **named): values = dict(zip(sequential, range(len(sequential))), **named) return type(name, (), values) -Status = enum('Status', QUEUED='queued', FINISHED='finished', FAILED='failed') +Status = enum('Status', QUEUED='queued', FINISHED='finished', FAILED='failed', + RUNNING='running') def unpickle(pickled_string): @@ -105,6 +106,10 @@ class Job(object): def is_failed(self): return self.status == Status.FAILED + @property + def is_running(self): + return self.status == Status.RUNNING + @property def func(self): func_name = self.func_name diff --git a/rq/worker.py b/rq/worker.py index c936262..91f3333 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -320,6 +320,8 @@ class Worker(object): self.state = 'busy' job, queue = result + # Use the public setter here, to immediately update Redis + job.status = Status.RUNNING self.log.info('%s: %s (%s)' % (green(queue.name), blue(job.description), job.id))