diff --git a/router.py b/router.py index 3869fd6..449821d 100644 --- a/router.py +++ b/router.py @@ -1,6 +1,6 @@ import asyncio import json -from typing import Dict, List +from typing import ClassVar, Dict, List from fastapi import WebSocket, WebSocketDisconnect from lnbits.helpers import urlsafe_short_hash @@ -16,9 +16,11 @@ class NostrRouter: - received_subscription_events: dict[str, List[EventMessage]] - received_subscription_notices: list[NoticeMessage] - received_subscription_eosenotices: dict[str, EndOfStoredEventsMessage] + received_subscription_events: ClassVar[dict[str, List[EventMessage]]] = {} + received_subscription_notices: ClassVar[list[NoticeMessage]] = [] + received_subscription_eosenotices: ClassVar[dict[str, EndOfStoredEventsMessage]] = ( + {} + ) def __init__(self, websocket: WebSocket): self.connected: bool = True @@ -75,6 +77,7 @@ async def _nostr_to_client(self): self._handle_notices() except Exception as e: logger.debug(f"Failed to handle response for client: '{e!s}'.") + await asyncio.sleep(1) await asyncio.sleep(0.1) async def _handle_subscriptions(self):