diff --git a/src/pretix/base/management/commands/runperiodic.py b/src/pretix/base/management/commands/runperiodic.py index cd07aad83..639b9b69b 100644 --- a/src/pretix/base/management/commands/runperiodic.py +++ b/src/pretix/base/management/commands/runperiodic.py @@ -38,6 +38,7 @@ import traceback from django.conf import settings from django.core.cache import cache from django.core.management.base import BaseCommand +from django.db import close_old_connections from django.dispatch.dispatcher import NO_RECEIVERS from pretix.helpers.periodic import SKIPPED @@ -79,6 +80,8 @@ class Command(BaseCommand): self.stdout.write(f'INFO Running {name}…') t0 = time.time() try: + # Check if the DB connection is still good, it might be closed if the previous task took too long. + close_old_connections() r = receiver(signal=periodic_task, sender=self) except Exception as err: if isinstance(err, KeyboardInterrupt):