Skip to content

Commit dbeb4c1

Browse files
committed
MOD: Live subcribe single write to transport
1 parent 33c5c96 commit dbeb4c1

File tree

3 files changed

+7
-2
lines changed

3 files changed

+7
-2
lines changed

CHANGELOG.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,7 @@
44

55
#### Bug fixes
66
- Fixed an issue where the `Live` client would not raise an exception when reading an incompatible DBN version
7+
- Fixed an issue where sending lots of subscriptions could cause a `BufferError`
78

89
## 0.24.1 - 2023-12-15
910

databento/live/protocol.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -283,6 +283,7 @@ def subscribe(
283283
stype_in_valid = validate_enum(stype_in, SType, "stype_in")
284284
symbols_list = optional_symbols_list_to_list(symbols, stype_in_valid)
285285

286+
subscription_bytes: list[bytes] = []
286287
for batch in chunk(symbols_list, SYMBOL_LIST_BATCH_SIZE):
287288
batch_str = ",".join(batch)
288289
message = SubscriptionRequest(
@@ -291,8 +292,9 @@ def subscribe(
291292
symbols=batch_str,
292293
start=optional_datetime_to_unix_nanoseconds(start),
293294
)
295+
subscription_bytes.append(bytes(message))
294296

295-
self.transport.write(bytes(message))
297+
self.transport.writelines(subscription_bytes)
296298

297299
def start(
298300
self,

databento/live/session.py

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -477,7 +477,7 @@ async def _connect_task(
477477
)
478478

479479
try:
480-
await asyncio.wait_for(
480+
session_id = await asyncio.wait_for(
481481
protocol.authenticated,
482482
timeout=AUTH_TIMEOUT_SECONDS,
483483
)
@@ -488,6 +488,8 @@ async def _connect_task(
488488
) from None
489489
except ValueError as exc:
490490
raise BentoError(f"User authentication failed: {exc!s}") from None
491+
else:
492+
logger.info("assigned session id %s", session_id)
491493

492494
logger.info(
493495
"authentication with remote gateway completed",

0 commit comments

Comments
 (0)