forked from reactive-python/reactpy-django
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathapps.py
28 lines (20 loc) · 838 Bytes
/
apps.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
import logging
from django.apps import AppConfig
from django.db.utils import DatabaseError
from django_idom.utils import ComponentPreloader, db_cleanup
_logger = logging.getLogger(__name__)
class DjangoIdomConfig(AppConfig):
name = "django_idom"
def ready(self):
# Populate the IDOM component registry when Django is ready
ComponentPreloader().run()
# Delete expired database entries
# Suppress exceptions to avoid issues with `manage.py` commands such as
# `test`, `migrate`, `makemigrations`, or any custom user created commands
# where the database may not be ready.
try:
db_cleanup(immediate=True)
except DatabaseError:
_logger.debug(
"Could not access IDOM database at startup. Skipping cleanup..."
)