mirror of https://github.com/rq/rq.git
Use job.return_value() instead of job.result when processing callbacks (#1801)
* Use job.return_value() instead of job.result when processing callbacks * job.return_value() should also support Redis server < 5.
This commit is contained in:
parent
54db2fa8d1
commit
acdeff385d
|
@ -743,6 +743,14 @@ class Job:
|
|||
self._cached_result = None
|
||||
|
||||
if not self.supports_redis_streams:
|
||||
if self._result is not None:
|
||||
return self._result
|
||||
|
||||
rv = self.connection.hget(self.key, 'result')
|
||||
if rv is not None:
|
||||
# cache the result
|
||||
self._result = self.serializer.loads(rv)
|
||||
return self._result
|
||||
return None
|
||||
|
||||
if not self._cached_result:
|
||||
|
|
|
@ -1035,10 +1035,10 @@ class Queue:
|
|||
pipeline.execute()
|
||||
|
||||
if job.failure_callback:
|
||||
job.failure_callback(job, self.connection, *sys.exc_info())
|
||||
job.failure_callback(job, self.connection, *sys.exc_info()) # type: ignore
|
||||
else:
|
||||
if job.success_callback:
|
||||
job.success_callback(job, self.connection, job.result)
|
||||
job.success_callback(job, self.connection, job.return_value()) # type: ignore
|
||||
|
||||
return job
|
||||
|
||||
|
|
|
@ -90,7 +90,7 @@ class WorkerCallbackTestCase(RQTestCase):
|
|||
self.assertEqual(job.get_status(), JobStatus.FINISHED)
|
||||
self.assertEqual(
|
||||
self.testconn.get('success_callback:%s' % job.id).decode(),
|
||||
job.result
|
||||
job.return_value()
|
||||
)
|
||||
|
||||
job = queue.enqueue(div_by_zero, on_success=save_result)
|
||||
|
|
Loading…
Reference in New Issue