From 1bc0c3d223714960b436577616cf127134ac2161 Mon Sep 17 00:00:00 2001 From: Vincent Driessen Date: Wed, 1 Aug 2012 13:51:01 +0200 Subject: [PATCH] Fix bug where pickling the return value caused an uncaught exception. --- rq/worker.py | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/rq/worker.py b/rq/worker.py index 8f3d665..9aba75e 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -359,6 +359,10 @@ class Worker(object): try: with death_penalty_after(job.timeout or 180): rv = job.perform() + + # Pickle the result in the same try-except block since we need to + # use the same exc handling when pickling fails + pickled_rv = dumps(rv) except Exception as e: fq = self.failed_queue self.log.exception(red(str(e))) @@ -374,7 +378,7 @@ class Worker(object): if rv is not None: p = self.connection.pipeline() - p.hset(job.key, 'result', dumps(rv)) + p.hset(job.key, 'result', pickled_rv) p.expire(job.key, self.rv_ttl) p.execute() else: