Skip to content

Commit 6803051

Browse files
committed
FIX: Relax session ID parsing in Python
1 parent 2e70139 commit 6803051

File tree

3 files changed

+15
-12
lines changed

3 files changed

+15
-12
lines changed

CHANGELOG.md

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,11 @@
11
# Changelog
22

3+
## 0.31.2 - TBD
4+
5+
#### Bug fixes
6+
- Removed live session ID parsing to `int`, that could cause a session to fail when
7+
nothing was wrong
8+
39
## 0.31.1 - 2024-03-20
410

511
#### Enhancements

databento/live/protocol.py

Lines changed: 5 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -80,23 +80,23 @@ def __init__(
8080
)
8181
self._gateway_decoder = GatewayDecoder()
8282

83-
self._authenticated: asyncio.Future[int] = asyncio.Future()
83+
self._authenticated: asyncio.Future[str | None] = asyncio.Future()
8484
self._disconnected: asyncio.Future[None] = asyncio.Future()
8585
self._started: bool = False
8686

8787
@property
88-
def authenticated(self) -> asyncio.Future[int]:
88+
def authenticated(self) -> asyncio.Future[str | None]:
8989
"""
9090
Future that completes when authentication with the gateway is
9191
completed.
9292
93-
The result will contain the session id if successful.
93+
The result will contain the session ID if successful.
9494
The exception will contain a BentoError if authentication
9595
fails for any reason.
9696
9797
Returns
9898
-------
99-
asyncio.Future[int]
99+
asyncio.Future[str | None]
100100
101101
"""
102102
return self._authenticated
@@ -391,10 +391,7 @@ def _(self, message: AuthenticationResponse) -> None:
391391
)
392392
self.transport.close()
393393
else:
394-
if message.session_id is None:
395-
session_id = 0
396-
else:
397-
session_id = int(message.session_id)
394+
session_id = message.session_id
398395

399396
logger.debug(
400397
"CRAM authenticated session id assigned `%s`",

databento/live/session.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -281,17 +281,17 @@ def __init__(
281281

282282
self._user_gateway: str | None = user_gateway
283283
self._port = port
284-
self._session_id: int = 0
284+
self._session_id: str | None = None
285285

286286
@property
287-
def session_id(self) -> int:
287+
def session_id(self) -> str | None:
288288
"""
289-
Return the authenticated session ID. A zero value indicates no session
289+
Return the authenticated session ID. A None value indicates no session
290290
has started.
291291
292292
Returns
293293
-------
294-
int
294+
str | None
295295
296296
"""
297297
return self._session_id

0 commit comments

Comments
 (0)