Skip to content

Commit

Permalink
v0.4.1
Browse files Browse the repository at this point in the history
Fix an issue where the heartbeat was not handling a timeout error and breaking the reconnection logic.
  • Loading branch information
andrewsayre authored Apr 25, 2019
2 parents f66115e + c5d9b36 commit dbdfe61
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
8 changes: 4 additions & 4 deletions pyheos/connection.py
Original file line number Diff line number Diff line change
Expand Up @@ -224,7 +224,8 @@ async def _heart_beat(self):
if last_activity > threshold:
try:
await self.commands.heart_beat()
except (ConnectionError, asyncio.IncompleteReadError):
except (ConnectionError, asyncio.IncompleteReadError,
asyncio.TimeoutError):
pass
await asyncio.sleep(self._heart_beat_interval / 2)

Expand All @@ -247,10 +248,9 @@ async def command(
pending_commands = self._pending_commands[command_name]
pending_commands.append(event)
# Send command
self._writer.write((uri + SEPARATOR).encode())
await self._writer.drain()

try:
self._writer.write((uri + SEPARATOR).encode())
await self._writer.drain()
response = await asyncio.wait_for(event.wait(), self.timeout)
except (ConnectionError, asyncio.TimeoutError) as error:
# Occurs when the connection breaks
Expand Down
4 changes: 2 additions & 2 deletions pyheos/const.py
Original file line number Diff line number Diff line change
@@ -1,12 +1,12 @@
"""Define consts for the pyheos package."""

__title__ = "pyheos"
__version__ = "0.4.0"
__version__ = "0.4.1"

CLI_PORT = 1255
DEFAULT_TIMEOUT = 10.0
DEFAULT_RECONNECT_DELAY = 10.0
DEFAULT_HEART_BEAT = 60.0
DEFAULT_HEART_BEAT = 10.0
DEFAULT_STEP = 5

STATE_CONNECTED = "connected"
Expand Down

0 comments on commit dbdfe61

Please sign in to comment.