diff --git a/CHANGELOG.md b/CHANGELOG.md index f5670c5..df8dcf5 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -1,5 +1,13 @@ # Changelog +## 0.44.1 - 2024-10-29 + +#### Enhancements +- Improved exception messages emitted by the `Live` client to always include contents of any `ErrorMsg` sent by the gateway + +#### Bug fixes +- Fixed an issue where calling `Live.stop` would not close the connection within a reasonable time + ## 0.44.0 - 2024-10-22 #### Enhancements diff --git a/databento/live/protocol.py b/databento/live/protocol.py index 78fa4fa..9ee3897 100644 --- a/databento/live/protocol.py +++ b/databento/live/protocol.py @@ -195,21 +195,20 @@ def connection_lost(self, exc: Exception | None) -> None: """ super().connection_lost(exc) if not self.disconnected.done(): - if exc is None: - logger.info("connection closed") - if self._error_msgs: - error_msg = ", ".join(self._error_msgs) - if len(self._error_msgs) > 1: - error_msg = f"The following errors occurred: {error_msg}" - self._error_msgs.clear() - self.disconnected.set_exception( - BentoError(error_msg), - ) - else: - self.disconnected.set_result(None) - else: + if self._error_msgs: + error_msg = ", ".join(self._error_msgs) + if len(self._error_msgs) > 1: + error_msg = f"The following errors occurred: {error_msg}" + self._error_msgs.clear() + + logger.error("gateway error: %s", exc) + self.disconnected.set_exception(BentoError(error_msg)) + elif exc is not None: logger.error("connection lost: %s", exc) self.disconnected.set_exception(exc) + else: + logger.info("connection closed") + self.disconnected.set_result(None) def eof_received(self) -> bool | None: """ diff --git a/databento/live/session.py b/databento/live/session.py index fb43502..34fbef7 100644 --- a/databento/live/session.py +++ b/databento/live/session.py @@ -440,8 +440,7 @@ def stop(self) -> None: return if self._transport.can_write_eof(): self._transport.write_eof() - else: - self._transport.close() + self._transport.close() def start(self) -> None: """ diff --git a/databento/version.py b/databento/version.py index 1b33897..7f532dc 100644 --- a/databento/version.py +++ b/databento/version.py @@ -1 +1 @@ -__version__ = "0.44.0" +__version__ = "0.44.1" diff --git a/pyproject.toml b/pyproject.toml index 0400d04..c795057 100644 --- a/pyproject.toml +++ b/pyproject.toml @@ -1,6 +1,6 @@ [tool.poetry] name = "databento" -version = "0.44.0" +version = "0.44.1" description = "Official Python client library for Databento" authors = [ "Databento ", diff --git a/tests/test_historical_bento.py b/tests/test_historical_bento.py index 17a4889..028903f 100644 --- a/tests/test_historical_bento.py +++ b/tests/test_historical_bento.py @@ -365,14 +365,15 @@ def test_to_parquet_overwrite( dbnstore = DBNStore.from_bytes(data=stub_data) parquet_path = tmp_path / "my_test.parquet" dbnstore.to_parquet(path=parquet_path) - assert parquet_path.stat().st_size == 9888 + parquet_size = parquet_path.stat().st_size # Act dbnstore.to_parquet(path=parquet_path) # Assert + assert parquet_size > 0 # Should be about ~9000 bytes assert parquet_path.exists() - assert parquet_path.stat().st_size == 9888 + assert parquet_path.stat().st_size == parquet_size def test_to_parquet_exclusive(