From b826d29b0d626d83653f4011946352e370fb5896 Mon Sep 17 00:00:00 2001 From: Mouse Reeve Date: Wed, 8 Sep 2021 10:20:44 -0700 Subject: [PATCH] Generate image task failing when transaction hasn't completed --- bookwyrm/models/book.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/bookwyrm/models/book.py b/bookwyrm/models/book.py index 8bed6924..ec1c14ec 100644 --- a/bookwyrm/models/book.py +++ b/bookwyrm/models/book.py @@ -4,6 +4,7 @@ import re from django.contrib.postgres.search import SearchVectorField from django.contrib.postgres.indexes import GinIndex from django.db import models +from django.db import transaction from django.dispatch import receiver from model_utils import FieldTracker from model_utils.managers import InheritanceManager @@ -361,4 +362,6 @@ def preview_image(instance, *args, **kwargs): changed_fields = instance.field_tracker.changed() if len(changed_fields) > 0: - generate_edition_preview_image_task.delay(instance.id) + transaction.on_commit( + lambda: generate_edition_preview_image_task.delay(instance.id) + )