forked from CGM_Public/pretix_original
runperiodic: Robustness against closed DB connections (#5314)
This commit is contained in:
@@ -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):
|
||||
|
||||
Reference in New Issue
Block a user