Skip to content

Commit

Permalink
Don't raise on existing subscription
Browse files Browse the repository at this point in the history
  • Loading branch information
marcelveldt committed Nov 20, 2024
1 parent 9336142 commit 589d9a4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
8 changes: 4 additions & 4 deletions aiosonos/api/namespaces/_base.py
Original file line number Diff line number Diff line change
Expand Up @@ -2,11 +2,10 @@

from __future__ import annotations

import logging
from collections.abc import Callable
from typing import TYPE_CHECKING, Any, TypeVar

from aiosonos.exceptions import AlreadySubscribed

if TYPE_CHECKING:
from aiosonos.api import SonosLocalWebSocketsApi

Expand All @@ -15,6 +14,8 @@
SubscribeCallbackType = Callable[[_T], None]
UnsubscribeCallbackType = Callable[[], None]

_LOGGER = logging.getLogger(__name__)


class SonosNameSpace:
"""Base/Model for namespace-specific Sonos controller."""
Expand Down Expand Up @@ -42,8 +43,7 @@ async def _handle_subscribe(
) -> UnsubscribeCallbackType:
"""Handle subscription logic."""
if event_id in self._listeners:
err_msg = f"Already subscribed to {event_id}"
raise AlreadySubscribed(err_msg)
_LOGGER.error("Duplicate subscription detected for %s", event_id)
await self.api.send_command(
namespace=self.namespace,
command="subscribe",
Expand Down
4 changes: 0 additions & 4 deletions aiosonos/exceptions.py
Original file line number Diff line number Diff line change
Expand Up @@ -61,7 +61,3 @@ def __init__(self, error_code: str, details: str | None = None) -> None:
super().__init__(f"Command failed: {details or error_code}")
self.error_code = error_code
self.details = details


class AlreadySubscribed(SonosException):
"""Raised when trying to subscribe to a target for which a subscription already exists."""

0 comments on commit 589d9a4

Please sign in to comment.