Skip to content

Commit d91df7c

Browse files
committed
Remove job from dependency's dependent_key on cancel
1 parent e4cefa5 commit d91df7c

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

rq/job.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1196,6 +1196,15 @@ def cancel(self, pipeline: Optional['Pipeline'] = None, enqueue_dependents: bool
11961196
if pipeline is None:
11971197
pipe.watch(self.dependents_key)
11981198
q.enqueue_dependents(self, pipeline=pipeline, exclude_job_id=self.id)
1199+
1200+
# Go through all dependencies and remove the current job from each dependency's dependents_key
1201+
for dependency in self.fetch_dependencies(pipeline=pipe):
1202+
if not dependency:
1203+
continue
1204+
1205+
dependents_key = dependency.dependents_key
1206+
pipe.srem(dependents_key, self.id)
1207+
11991208
self._remove_from_registries(pipeline=pipe, remove_from_queue=True)
12001209

12011210
registry = CanceledJobRegistry(

0 commit comments

Comments
 (0)