Chain call times out

adam.leroux
adam.leroux Newcomer
edited May 26 in Workspace SDK

Hello,

I'm having a weird issue related to the refinitiv data API, especially the rd.discovery.Chain class.

I'm using this class to retrieve components of governmental yield curves, by create a Chain class with the chain RIC that i need, then using the .constituents method to retreive the information.

This works well 90% of the time. However sometimes the rd.discovery.Chain call just hangs undefinitly. The RIC passed is the correct chain RIC, in fact if i restart my API connection, the call works well, so it is not an issue of input.

There is no common factors in the RICs that cause this, i would say this issues appears in 1 in 20 calls.

I'm using a plateform session initialized with

rd.open_session(config_name='credentials.json')

Has anyone experience that issue before ?

Thanks for your help.

Answers

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @adam.leroux

    Thank you for reaching out to us.

    Please try the new LSEG Data Library for Python which is a rebranded version of the Refinitiv Data Library.

    The examples are available on GitHub.

    If the problem still occurs, please enable the debug logging in the library by running the following code before opening a session.

    config = ld.get_config()
    config.set_param("logs.transports.file.enabled", True)
    config.set_param("logs.transports.file.name", "lseg-data-lib.log")
    config.set_param("logs.level", "debug")
    ld.open_session(…)

    With this code, the debug log file will be created.

    Please remove any private information from the log file and then share it.

    We can verify the behavior of the library from the log file.

  • adam.leroux
    adam.leroux Newcomer

    I will check the new version of the package and let you know. Thank you

  • adam.leroux
    adam.leroux Newcomer

    Hello @Jirapongse ,

    I've now migrated my to lseg-data, and added logging to my code.

    I've identify an example of the issue above, attached is the relevant log information for that call.

    I think the API call hangs after this step :

    [release] - StreamCxnCache release (item=CacheItem(cxn=Thread

    OMMSTREAMING_CHAINS_0.0, number_in_use=0), content_type=ContentType.STREAMING_CHAINS, session=ldp)

    Let me know what other information I need to provide to debug this further.

    Thank you very much for your support.

    Best,

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    I couldn't see any problems in the log file.

    [2025-05-27T11:50:20.857085+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125741429719040 - MainThread] - [_stream] - [_do_close] - StreamingChain id=0 name='0#IEBMK=' [PrvOMMStream id=5 name='0#IEBMK='] send close_message {"ID": 5, "Type": "Close"}
    [2025-05-27T11:50:20.862842+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125741429719040 - MainThread] - [stream_connection] - [send_message] - [OMMSTREAMING_CHAINS_0.0] send {"ID": 5, "Type": "Close"}

    [2025-05-27T11:50:20.867991+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125741429719040 - MainThread] - [_stream] - [_do_close] - StreamingChain id=0 name='0#IEBMK=' [PrvOMMStream id=5 name='0#IEBMK='] release cxn=ThreadOMMSTREAMING_CHAINS_0.0

    [2025-05-27T11:50:20.872833+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125741429719040 - MainThread] - [_stream_cxn_cache] - [release] - StreamCxnCache release (item=CacheItem(cxn=ThreadOMMSTREAMING_CHAINS_0.0, number_in_use=0), content_type=ContentType.STREAMING_CHAINS, session=ldp)

    I think the item stream (0#IEBMK=) was closed so it released the cache of that item.

    The connect is still alive and I could see ping and pong messages.

    [2025-05-27T11:52:00.532792+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125738455922240 - ThreadOMMSTREAMING_CHAINS_0.0] - [stream_connection] - [_on_message] - [OMMSTREAMING_CHAINS_0.0] queued with priority 1: {"Type": "Ping"}
    [2025-05-27T11:52:00.539487+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125738547820096 - Msg-Proc-ThreadOMMSTREAMING_CHAINS_0.0] - [omm_stream_connection] - [_process_message] - [OMMSTREAMING_CHAINS_0.0] process message {"Type": "Ping"}
    [2025-05-27T11:52:00.545950+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125738547820096 - Msg-Proc-ThreadOMMSTREAMING_CHAINS_0.0] - [stream_connection] - [send_message] - [OMMSTREAMING_CHAINS_0.0] send {"Type": "Pong"}
    [2025-05-27T11:52:00.555531+00:00] - [sessions.platform.ldp.0] - [DEBUG] - [125738547820096 - Msg-Proc-ThreadOMMSTREAMING_CHAINS_0.0] - [stream_connection] - [_get_messages] - [OMMSTREAMING_CHAINS_0.0] received messages: 6 | processed messages: 6

    Is it possible to share the runnable code? I need it to replicate the issue on my machine.

  • adam.leroux
    adam.leroux Newcomer

    Unfortunately i cannot share this code. However i will try to make a dummy code that has the same issue.

  • adam.leroux
    adam.leroux Newcomer

    Hi @Jirapongse

    Can you test the attached notebook ?

    Its a code that will iterate over many country codes and try to find a YC chain ric, if it doesnt exist, it will just return none. When i run it , it get None for the first country, as is expected, but the code hangs at the second country's Chain.constituents call.

  • adam.leroux
    adam.leroux Newcomer

    I noticed i included a "_maturity_from_ric" function in my exemple, you can discard it it is not needed in this .

  • Jirapongse
    Jirapongse ✭✭✭✭✭

    @adam.leroux

    Thank you for the code.

    I found that most chain RICs are invalid. When a chain RIC is invalid, it causes an exception in an internal thread and the library stops working. The workaround could be use the Search API to verify if a chain RIC is valid. For example:

    def _curve_nodes(country_iso: str) -> dict[str, float]:
    """
    Return {ric: maturity_in_years} for all benchmark nodes available for
    the given sovereign, using the chain RIC (e.g. 0#FRBMK=).
    """
    try:
    chn_ric = f"0#{country_iso.upper()}BMK="
    df = ld.discovery.search(
    view = ld.discovery.Views.SEARCH_ALL,
    query = chn_ric,
    top=1
    )
    if len(df) != 0:
    nodes = Chain(chn_ric).constituents
    print(nodes)
    else:
    print(chn_ric+ ":" + "Not Found")
    return None
    except LDError as e:
    print("### Exception ####")
    #print(e)
    return None
    print(chn_ric)


    return nodes