From 501a3870e16fe94e44a3e939c1df1c2abe90c220 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Fri, 15 Feb 2013 10:22:31 +0100 Subject: [PATCH] Ignore a job when there isn't a "data" key available. --- rq/job.py | 8 ++++++-- 1 file changed, 6 insertions(+), 2 deletions(-) diff --git a/rq/job.py b/rq/job.py index 4d625bf..a0367ee 100644 --- a/rq/job.py +++ b/rq/job.py @@ -256,7 +256,7 @@ class Job(object): """ key = self.key obj = self.connection.hgetall(key) - if not obj: + if len(obj) == 0: raise NoSuchJobError('No such job: %s' % (key,)) def to_date(date_str): @@ -265,7 +265,11 @@ class Job(object): else: return times.to_universal(date_str) - self.data = obj.get('data') + try: + self.data = obj['data'] + except KeyError: + raise NoSuchJobError('Unexpected job format: {0}'.format(obj)) + try: self._func_name, self._instance, self._args, self._kwargs = unpickle(self.data) except UnpickleError: