Skip to content

Commit

Permalink
Fix is_alive (#142)
Browse files Browse the repository at this point in the history
  • Loading branch information
epenet authored Nov 28, 2024
1 parent 8ee4242 commit 51081bc
Show file tree
Hide file tree
Showing 2 changed files with 7 additions and 2 deletions.
3 changes: 2 additions & 1 deletion samsungtvws/async_connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -24,6 +24,7 @@

from websockets.asyncio.client import ClientConnection, connect
from websockets.exceptions import ConnectionClosed
from websockets.protocol import State

from . import connection, exceptions, helper
from .command import SamsungTVCommand, SamsungTVSleepCommand
Expand Down Expand Up @@ -174,4 +175,4 @@ async def _send_command(
await asyncio.sleep(delay)

def is_alive(self) -> bool:
return self.connection is not None and not self.connection.closed
return self.connection is not None and self.connection.state is not State.CLOSED
6 changes: 5 additions & 1 deletion samsungtvws/encrypted/remote.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,6 +10,7 @@
import aiohttp
from websockets.asyncio.client import ClientConnection, connect
from websockets.exceptions import ConnectionClosed
from websockets.protocol import State

from ..exceptions import ConnectionFailure
from .command import SamsungTVEncryptedCommand
Expand Down Expand Up @@ -183,4 +184,7 @@ async def close(self) -> None:
LOGGER.debug("Connection closed")

def is_alive(self) -> bool:
return self._connection is not None and not self._connection.closed
return (
self._connection is not None
and not self._connection.state is not State.CLOSED
)

0 comments on commit 51081bc

Please sign in to comment.