Skip to content

Commit 732873d

Browse files
authored
Remove db_cleanup from startup (#140)
1 parent 6bbb279 commit 732873d

File tree

3 files changed

+7
-20
lines changed

3 files changed

+7
-20
lines changed

CHANGELOG.md

+4
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,10 @@ Using the following categories, list your changes in this order:
3434

3535
## [Unreleased]
3636

37+
### Removed
38+
39+
- `django-reactpy` database entries are no longer cleaned during Django application startup. Instead, it will occur on webpage loads if `REACTPY_RECONNECT_MAX` seconds has elapsed since the last cleaning.
40+
3741
## [3.0.0-reactpy] - 2023-03-30
3842

3943
### Changed

src/reactpy_django/apps.py

+1-18
Original file line numberDiff line numberDiff line change
@@ -1,12 +1,6 @@
1-
import logging
2-
31
from django.apps import AppConfig
4-
from django.db.utils import DatabaseError
5-
6-
from reactpy_django.utils import ComponentPreloader, db_cleanup
72

8-
9-
_logger = logging.getLogger(__name__)
3+
from reactpy_django.utils import ComponentPreloader
104

115

126
class ReactPyConfig(AppConfig):
@@ -15,14 +9,3 @@ class ReactPyConfig(AppConfig):
159
def ready(self):
1610
# Populate the ReactPy component registry when Django is ready
1711
ComponentPreloader().run()
18-
19-
# Delete expired database entries
20-
# Suppress exceptions to avoid issues with `manage.py` commands such as
21-
# `test`, `migrate`, `makemigrations`, or any custom user created commands
22-
# where the database may not be ready.
23-
try:
24-
db_cleanup(immediate=True)
25-
except DatabaseError:
26-
_logger.debug(
27-
"Could not access ReactPy database at startup. Skipping cleanup..."
28-
)

tests/test_app/asgi.py

+2-2
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,6 @@
1111

1212
from django.core.asgi import get_asgi_application
1313

14-
from reactpy_django import REACTPY_WEBSOCKET_PATH
15-
1614

1715
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "test_app.settings")
1816

@@ -23,6 +21,8 @@
2321
from channels.routing import ProtocolTypeRouter, URLRouter # noqa: E402
2422
from channels.sessions import SessionMiddlewareStack # noqa: E402
2523

24+
from reactpy_django import REACTPY_WEBSOCKET_PATH # noqa: E402
25+
2626

2727
application = ProtocolTypeRouter(
2828
{

0 commit comments

Comments
 (0)