Skip to content

Commit 8f5643b

Browse files
authored
Wait for Django apps to be ready before running massmail
1 parent 78864f1 commit 8f5643b

File tree

1 file changed

+3
-1
lines changed

1 file changed

+3
-1
lines changed

massmail/utils/sendmassmail.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,6 +12,7 @@
1212
from tendo.singleton import SingleInstance
1313
from typing import Optional
1414
from typing import Union
15+
from django.apps import apps
1516
from django.conf import settings
1617
from django.contrib.auth import get_user_model
1718
from django.contrib.contenttypes.models import ContentType
@@ -50,7 +51,8 @@ def __init__(self, *args, **kwargs):
5051
SingleInstance.__init__(self, flavor_id='Massmail')
5152

5253
def run(self):
53-
time.sleep(0.01) # wait for django to start
54+
while not apps.ready:
55+
time.sleep(0.01) # wait for django to start
5456
massmail_settings = MassmailSettings.objects.get(id=1)
5557
if not settings.MAILING or settings.TESTING:
5658
return

0 commit comments

Comments
 (0)