Fix critical bugs

This commit is contained in:
2026-02-20 14:30:45 +00:00
parent dba4122653
commit 9118913c6b
7 changed files with 82 additions and 25 deletions

View File

@@ -17,6 +17,9 @@ logger = logging.getLogger(__name__)
PREFIX_PO_PARAM = "notification_po_"
# Keep references to background tasks to prevent garbage collection
_background_tasks: set[asyncio.Task] = set()
class NotificationManagerService:
"""Manages notification processing and integration with conversations.
@@ -127,6 +130,8 @@ class NotificationManagerService:
)
# Fire and forget - don't await
_task = asyncio.create_task(save_notification_to_firestore())
task = asyncio.create_task(save_notification_to_firestore())
# Store reference to prevent premature garbage collection
del _task
_background_tasks.add(task)
# Remove from set when done to prevent memory leak
task.add_done_callback(_background_tasks.discard)