From d660b611db869589f0333a2ffd013eb6ee32cea3 Mon Sep 17 00:00:00 2001 From: Javier Rey Date: Sat, 12 Jan 2013 16:37:25 -0200 Subject: [PATCH] ended_at time is now saved when job is finished --- rq/worker.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/rq/worker.py b/rq/worker.py index ee3c317..140b1c0 100644 --- a/rq/worker.py +++ b/rq/worker.py @@ -3,6 +3,7 @@ import os import errno import random import time +import times try: from procname import setprocname except ImportError: @@ -399,6 +400,7 @@ class Worker(object): # use the same exc handling when pickling fails pickled_rv = dumps(rv) job._status = Status.FINISHED + job.ended_at = times.now() except: # Use the public setter here, to immediately update Redis job.status = Status.FAILED @@ -424,6 +426,7 @@ class Worker(object): p = self.connection.pipeline() p.hset(job.key, 'result', pickled_rv) p.hset(job.key, 'status', job._status) + p.hset(job.key, 'ended_at', times.format(job.ended_at, 'UTC')) if result_ttl > 0: p.expire(job.key, result_ttl) self.log.info('Result is kept for %d seconds.' % result_ttl)