File tree Expand file tree Collapse file tree 3 files changed +43
-5
lines changed
Expand file tree Collapse file tree 3 files changed +43
-5
lines changed Original file line number Diff line number Diff line change 22
33## 0.27.0 - TBD
44
5+ #### Enhancements
6+ - Added ` Session.session_id ` property which will contain the numerical session ID once a live session has been authenticated
7+
58#### Breaking changes
69- Renamed ` DatatbentoLiveProtocol.started ` to ` DatatbentoLiveProtocol.is_started ` which now returns a bool instead of an ` asyncio.Event `
710
Original file line number Diff line number Diff line change @@ -227,6 +227,20 @@ def __init__(
227227
228228 self ._user_gateway : str | None = user_gateway
229229 self ._port = port
230+ self ._session_id : int = 0
231+
232+ @property
233+ def session_id (self ) -> int :
234+ """
235+ Return the authenticated session ID. A zero value indicates no session
236+ has started.
237+
238+ Returns
239+ -------
240+ int
241+
242+ """
243+ return self ._session_id
230244
231245 def is_authenticated (self ) -> bool :
232246 """
@@ -489,13 +503,11 @@ async def _connect_task(
489503 f"Authentication with { gateway } :{ port } timed out after "
490504 f"{ AUTH_TIMEOUT_SECONDS } second(s)." ,
491505 ) from None
492- except ValueError as exc :
493- raise BentoError (f"User authentication failed: { exc !s} " ) from None
494- else :
495- logger .info ("assigned session id %s" , session_id )
496506
507+ self ._session_id = session_id
497508 logger .info (
498- "authentication with remote gateway completed" ,
509+ "authenticated session %s" ,
510+ self .session_id ,
499511 )
500512
501513 return transport , protocol
Original file line number Diff line number Diff line change @@ -405,6 +405,29 @@ def test_live_subscribe(
405405 assert message .start == start
406406
407407
408+ @pytest .mark .usefixtures ("mock_live_server" )
409+ async def test_live_subscribe_session_id (
410+ live_client : client .Live ,
411+ ) -> None :
412+ """
413+ Test that a session ID is assigned after the connection is authenticated.
414+ """
415+ # Arrange
416+ old_session_id = live_client ._session .session_id
417+
418+ # Act
419+ live_client .subscribe (
420+ dataset = Dataset .GLBX_MDP3 ,
421+ schema = Schema .MBO ,
422+ stype_in = SType .RAW_SYMBOL ,
423+ symbols = ALL_SYMBOLS ,
424+ )
425+
426+ # Assert
427+ assert live_client ._session .session_id != old_session_id
428+ assert live_client ._session .session_id != 0
429+
430+
408431@pytest .mark .skipif (platform .system () == "Windows" , reason = "timeout on windows" )
409432async def test_live_subscribe_large_symbol_list (
410433 live_client : client .Live ,
You can’t perform that action at this time.
0 commit comments