SurfSense/surfsense_backend/app/notifications/__init__.py
CREDO23 620c378254 fix(notifications): break db <-> notifications.persistence circular import
When app.notifications is the import entry point (e.g. Celery loading
app.notifications.service before any ORM code), app.db re-entered the
half-initialized app.notifications.persistence at its model-registration import
and failed with "cannot import name 'Notification' ... partially initialized".

Import app.db at the top of app/notifications/__init__.py so db fully initializes
(including its own Notification registration) before we re-import from
.persistence. Pre-existing issue (reproduces on the base commit); surfaced by the
celery worker startup.
2026-06-05 17:10:43 +02:00

19 lines
608 B
Python

"""User notifications: persistence, service, and HTTP API.
Emit notifications via :class:`~app.notifications.service.NotificationService`;
the router in :mod:`app.notifications.api` exposes the inbox endpoints.
"""
from __future__ import annotations
# Initialize app.db first to avoid a partial-init circular import when this
# package is the entry point (e.g. Celery loading it before any ORM code).
import app.db # noqa: F401
from app.notifications.persistence import Notification
from app.notifications.service import NotificationService
__all__ = [
"Notification",
"NotificationService",
]