job.cancel() now deletes dependents_key

main
Selwin Ong 11 years ago
parent 7fdd115e28
commit 8aa5771646

@ -371,12 +371,12 @@ class Job(object):
deleting the job hash.
"""
self.delete()
self.connection.delete(self.dependents_key)
def delete(self):
"""Deletes the job hash from Redis."""
self.connection.delete(self.key)
# Job execution
def perform(self): # noqa
"""Invokes the job function with the job arguments."""

@ -290,3 +290,14 @@ class TestJob(RQTestCase):
job.save()
job.register_dependency()
self.assertEqual(as_text(self.testconn.spop('rq:job:id:dependents')), job.id)
def test_cancel(self):
"""job.cancel() deletes itself & dependents mapping from Redis."""
job = Job.create(func=say_hello)
job_key = job.key
dependents_key = job.dependents_key
job2 = Job.create(func=say_hello, depends_on=job)
job2.register_dependency()
job.cancel()
self.assertFalse(self.testconn.exists(job.key))
self.assertFalse(self.testconn.exists(job.dependents_key))

Loading…
Cancel
Save