Set ended_at for a job when using is_async=False (#2142)

* set ended_at for is_async=False job

* added test to check ended_at is set for is_async=False job
This commit is contained in:
Alex Prabhat Bara 2024-11-16 13:26:51 +05:30 committed by GitHub
parent faa7b024d6
commit dbbbd09463
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
2 changed files with 6 additions and 0 deletions

View File

@ -877,6 +877,7 @@ class Queue:
Job: _description_
"""
job.perform()
job.ended_at = now()
result_ttl = job.get_result_ttl(default_ttl=DEFAULT_RESULT_TTL)
with self.connection.pipeline() as pipeline:
job._handle_success(result_ttl=result_ttl, pipeline=pipeline)

View File

@ -389,6 +389,11 @@ class TestQueue(RQTestCase):
keep_job = queue.enqueue(echo, result_ttl=100)
self.assertLessEqual(queue.connection.ttl(keep_job.key), 100)
def test_synchronous_ended_at(self):
queue = Queue(is_async=False, connection=self.connection)
echo_job = queue.enqueue(echo)
self.assertIsNotNone(echo_job.ended_at)
def test_enqueue_explicit_args(self):
"""enQueue(connection=self.connection) works for both implicit/explicit args."""
q = Queue(connection=self.connection)