Merge pull request #266 from selwin/cancel-dependents

Canceling a job should also delete its dependents_key
main
Vincent Driessen 11 years ago
commit 20f4bb5138

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

@ -290,3 +290,12 @@ class TestJob(RQTestCase):
job.save() job.save()
job.register_dependency() job.register_dependency()
self.assertEqual(as_text(self.testconn.spop('rq:job:id:dependents')), job.id) 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)
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