Skip to content

Commit 905c743

Browse files
authored
Merge pull request #352 from dvd-dev/fix_websocket_loop
Update websocket.py
2 parents 11e9d9e + 9841481 commit 905c743

File tree

4 files changed

+11
-3
lines changed

4 files changed

+11
-3
lines changed

pyhilo/const.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
LOG: Final = logging.getLogger(__package__)
88
DEFAULT_STATE_FILE: Final = "hilo_state.yaml"
99
REQUEST_RETRY: Final = 9
10-
PYHILO_VERSION: Final = "2025.12.01"
10+
PYHILO_VERSION: Final = "2025.12.02"
1111
# TODO: Find a way to keep previous line in sync with pyproject.toml automatically
1212

1313
CONTENT_TYPE_FORM: Final = "application/x-www-form-urlencoded"

pyhilo/event.py

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -108,8 +108,9 @@ def _convert_phases(self, phases: dict[str, Any]) -> None:
108108
self.phases_list.append(phase)
109109
for phase in self.__annotations__:
110110
if phase not in self.phases_list:
111+
now_with_tz = datetime.now(timezone.utc).astimezone()
111112
# On t'aime Carl
112-
setattr(self, phase, from_utc_timestamp("2023-11-15T20:00:00+00:00"))
113+
setattr(self, phase, now_with_tz)
113114

114115
def _create_phases(
115116
self, hours: int, phase_name: str, parent_phase: str

pyhilo/websocket.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -274,6 +274,10 @@ async def async_connect(self) -> None:
274274
LOG.debug("Websocket: async_connect() called but already connected")
275275
return
276276

277+
if self._api.session.closed:
278+
LOG.error("Websocket: Cannot connect, session is closed")
279+
raise CannotConnectError("Session is closed")
280+
277281
LOG.info("Websocket: Connecting to server %s", self._api.endpoint)
278282
if self._api.log_traces:
279283
LOG.debug("[TRACE] Websocket URL: %s", self._api.full_ws_url)
@@ -344,6 +348,9 @@ async def async_listen(self) -> None:
344348
messages = await self._async_receive_json()
345349
for msg in messages:
346350
self._parse_message(msg)
351+
except asyncio.CancelledError:
352+
LOG.info("Websocket: Listen cancelled.")
353+
raise
347354
except ConnectionClosedError as err:
348355
LOG.error(f"Websocket: Closed while listening: {err}")
349356
LOG.exception(err)

pyproject.toml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -40,7 +40,7 @@ exclude = ".venv/.*"
4040

4141
[tool.poetry]
4242
name = "python-hilo"
43-
version = "2025.12.1"
43+
version = "2025.12.2"
4444
description = "A Python3, async interface to the Hilo API"
4545
readme = "README.md"
4646
authors = ["David Vallee Delisle <[email protected]>"]

0 commit comments

Comments
 (0)