Skip to content

Commit f975acd

Browse files
authored
Merge pull request #320 from MULTidll/main
Added Exception Handling for settings_massmailsettings Resolves #305
2 parents 257f102 + 4a1af36 commit f975acd

File tree

1 file changed

+9
-1
lines changed

1 file changed

+9
-1
lines changed

massmail/utils/sendmassmail.py

Lines changed: 9 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@
2424
from django.utils import timezone
2525
from django.utils.formats import date_format
2626
from django.utils.translation import gettext_lazy as _
27+
from django.db.utils import OperationalError
2728

2829
from common.utils.helpers import get_formatted_short_date
2930
from common.utils.helpers import get_now
@@ -53,7 +54,14 @@ def __init__(self, *args, **kwargs):
5354
def run(self):
5455
while not apps.ready:
5556
time.sleep(0.01) # wait for django to start
56-
massmail_settings = MassmailSettings.objects.get(id=1)
57+
58+
while True: #This will wait for the db to be ready
59+
try:
60+
massmail_settings = MassmailSettings.objects.get(id=1)
61+
break
62+
except (OperationalError, MassmailSettings.DoesNotExist):
63+
time.sleep(1)
64+
5765
if not settings.MAILING or settings.TESTING:
5866
return
5967

0 commit comments

Comments
 (0)