runperiodic: Robustness against closed DB connections (#5314)

This commit is contained in:
Raphael Michel
2025-07-16 15:35:19 +02:00
committed by GitHub
parent 149f1ee871
commit 0dd66f9468

View File

@@ -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):