From 38f0e6e6d65670752e299a18c4f312bb056c7c81 Mon Sep 17 00:00:00 2001 From: Raphael Michel Date: Mon, 18 Apr 2016 17:50:03 +0200 Subject: [PATCH] Added a delay to invoice generation --- src/pretix/base/services/invoices.py | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/pretix/base/services/invoices.py b/src/pretix/base/services/invoices.py index 4cd9940fe..433d3d019 100644 --- a/src/pretix/base/services/invoices.py +++ b/src/pretix/base/services/invoices.py @@ -332,4 +332,7 @@ if settings.HAS_CELERY: invoice_pdf_task = app.task(invoice_pdf) def invoice_pdf(*args, **kwargs): - invoice_pdf_task.apply_async(args=args, kwargs=kwargs) + # We introduce a 2 second delay, because otherwise we run into conditions where + # the task worker tries to generate the PDF even before our database transaction + # was committed and therefore fails to find the invoice object. + invoice_pdf_task.apply_async(args=args, kwargs=kwargs, countdown=2)