From 3d0138d31961035d9411efce38fb18420551ad45 Mon Sep 17 00:00:00 2001 From: Marc Brinkmann Date: Wed, 25 Sep 2013 11:14:28 +0200 Subject: [PATCH] Added Worker.get_current_job() convenience method. --- rq/worker.py | 9 +++++++++ 1 file changed, 9 insertions(+) diff --git a/rq/worker.py b/rq/worker.py index 03610aa..37ae655 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -242,6 +242,15 @@ class Worker(object): job_id = property(get_job_id, set_job_id) + # most client will want to use the method below to query the current job + def get_current_job(self): + job_id = self.get_job_id() + + if job_id is None: + return None + + return Job.safe_fetch(job_id) + @property def stopped(self): return self._stopped