|
|
@ -398,13 +398,20 @@ class Worker(object):
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
self.log.info('Job OK, result = %s' % (yellow(unicode(rv)),))
|
|
|
|
self.log.info('Job OK, result = %s' % (yellow(unicode(rv)),))
|
|
|
|
|
|
|
|
|
|
|
|
if rv is not None:
|
|
|
|
# Expire results
|
|
|
|
|
|
|
|
has_result = rv is not None
|
|
|
|
|
|
|
|
explicit_ttl_requested = job.result_ttl is not None
|
|
|
|
|
|
|
|
should_expire = has_result or explicit_ttl_requested
|
|
|
|
|
|
|
|
if should_expire:
|
|
|
|
p = self.connection.pipeline()
|
|
|
|
p = self.connection.pipeline()
|
|
|
|
p.hset(job.key, 'result', pickled_rv)
|
|
|
|
p.hset(job.key, 'result', pickled_rv)
|
|
|
|
if job.result_ttl is None:
|
|
|
|
|
|
|
|
p.expire(job.key, self.default_result_ttl)
|
|
|
|
if explicit_ttl_requested:
|
|
|
|
elif job.result_ttl >= 0:
|
|
|
|
ttl = job.result_ttl
|
|
|
|
p.expire(job.key, job.result_ttl)
|
|
|
|
else:
|
|
|
|
|
|
|
|
ttl = self.default_result_ttl
|
|
|
|
|
|
|
|
if ttl >= 0:
|
|
|
|
|
|
|
|
p.expire(job.key, ttl)
|
|
|
|
p.execute()
|
|
|
|
p.execute()
|
|
|
|
else:
|
|
|
|
else:
|
|
|
|
# Cleanup immediately
|
|
|
|
# Cleanup immediately
|
|
|
|