lseg-data open_session(). How to get error code and message?

Tethys
Tethys Newcomer

If I run

desktop_session = ld.open_session('desktop.workspace')

with incorrect key or when LSEG Workspace is down, I see that:

desktop_session.open_state == "Closed"

How can I get the error code and message of why it couldn't open the session?

I can see this data is in the log file. Can I get it from the code?

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @Tethys

    Thank you for reaching out to us.

    I found that the session supports the state and event callback methods by using the following code.

    def state_callback(state_code, text, session):
        print("state_callback:",state_code, text )
    
    def event_callback(event_code, text, session):
        print("event_callback", event_code, text)
    
    session = ld.session.desktop.Definition(app_key = "123454565").get_session()
    session.on_state(state_callback)
    session.on_event(event_callback)
    session.open()
    

    The output is:

    image.png