Skip to content

Commit ce58cd8

Browse files
committed
MOD: Raise disconnection exception in iteration
1 parent a5e6c23 commit ce58cd8

File tree

4 files changed

+12
-4
lines changed

4 files changed

+12
-4
lines changed

CHANGELOG.md

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -2,8 +2,12 @@
22

33
## 0.19.2 - TBD
44

5-
### Enhancements
5+
#### Enhancements
66
- Added `ARCX.PILLAR.ARCX` publisher
7+
- Added `map_symbols` option for `batch.submit_job(...)`, default `False`. When `True` this appends a requested symbol field to each record (available for CSV and JSON text encodings)
8+
9+
#### Bug fixes
10+
- Fixed an issue where no disconnection exception were raised when iterating the `Live` client.
711

812
## 0.19.1 - 2023-09-08
913

databento/live/client.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -156,6 +156,7 @@ def __next__(self) -> DBNRecord:
156156
self._session.resume_reading()
157157

158158
self._dbn_queue._enabled.clear()
159+
self.block_for_close()
159160
raise StopIteration
160161

161162
def __repr__(self) -> str:
@@ -528,8 +529,9 @@ def block_for_close(
528529
self.terminate()
529530
if isinstance(exc, KeyboardInterrupt):
530531
raise
532+
except BentoError:
533+
raise
531534
except Exception:
532-
logger.exception("exception encountered blocking for close")
533535
raise BentoError("connection lost") from None
534536

535537
async def wait_for_close(

databento/live/protocol.py

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -194,7 +194,7 @@ def connection_made(self, transport: asyncio.BaseTransport) -> None:
194194

195195
def connection_lost(self, exc: Exception | None) -> None:
196196
"""
197-
Override of `connection_list`.
197+
Override of `connection_lost`.
198198
199199
See Also
200200
--------
@@ -356,6 +356,9 @@ def _process_dbn(self, data: bytes) -> None:
356356
"gateway error: %s",
357357
record.err,
358358
)
359+
self.disconnected.set_exception(
360+
BentoError(record.err),
361+
)
359362
if isinstance(record, databento_dbn.SystemMsg):
360363
if record.is_heartbeat:
361364
logger.debug("gateway heartbeat")

tests/test_live_client.py

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -730,7 +730,6 @@ def test_live_sync_iteration(
730730
assert isinstance(records[2], databento_dbn.MBOMsg)
731731
assert isinstance(records[3], databento_dbn.MBOMsg)
732732

733-
734733
async def test_live_callback(
735734
live_client: client.Live,
736735
) -> None:

0 commit comments

Comments
 (0)