From 5a17c2794e4a2c022b9003f8d9b79cfefd25974d Mon Sep 17 00:00:00 2001 From: Philipp Mayer Date: Mon, 9 May 2022 14:17:36 +0200 Subject: [PATCH] ~ catch Entry.DoesNotExist --- src/showroom_connector/signals.py | 14 ++++++++++---- 1 file changed, 10 insertions(+), 4 deletions(-) diff --git a/src/showroom_connector/signals.py b/src/showroom_connector/signals.py index abf3a804..88b81120 100644 --- a/src/showroom_connector/signals.py +++ b/src/showroom_connector/signals.py @@ -63,10 +63,16 @@ def relation_post_save(sender, instance, *args, **kwargs): @receiver(post_delete, sender=Relation, dispatch_uid='showroom_connector_relation_post_delete') def relation_post_delete(sender, instance, *args, **kwargs): if settings.SYNC_TO_SHOWROOM: - if instance.from_entry.published and instance.to_entry.published: - queue = django_rq.get_queue('default') - queue.enqueue(sync.push_relations, entry=instance.from_entry) - # TODO: discuss and implement failure handling + try: + if instance.from_entry.published and instance.to_entry.published: + queue = django_rq.get_queue('default') + queue.enqueue(sync.push_relations, entry=instance.from_entry) + # TODO: discuss and implement failure handling + except Entry.DoesNotExist: + # Entry has already been deleted, so the corresponding request to + # Showroom should already have deleted all corresponding relations + # there as well, so it's not necessary to do anything further + pass @receiver(post_save, sender=Media, dispatch_uid='showroom_connector_media_post_save')