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.
main
Selwin Ong 2 years ago committed by GitHub
parent 54db2fa8d1
commit acdeff385d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

@ -743,6 +743,14 @@ class Job:
self._cached_result = None self._cached_result = None
if not self.supports_redis_streams: 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 return None
if not self._cached_result: if not self._cached_result:

@ -1035,10 +1035,10 @@ class Queue:
pipeline.execute() pipeline.execute()
if job.failure_callback: 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: else:
if job.success_callback: 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 return job

@ -90,7 +90,7 @@ class WorkerCallbackTestCase(RQTestCase):
self.assertEqual(job.get_status(), JobStatus.FINISHED) self.assertEqual(job.get_status(), JobStatus.FINISHED)
self.assertEqual( self.assertEqual(
self.testconn.get('success_callback:%s' % job.id).decode(), self.testconn.get('success_callback:%s' % job.id).decode(),
job.result job.return_value()
) )
job = queue.enqueue(div_by_zero, on_success=save_result) job = queue.enqueue(div_by_zero, on_success=save_result)

Loading…
Cancel
Save