Upgrade from Eikon -> Workspace. Learn about programming differences.

For a deeper look into our Eikon Data API, look into:

Overview |  Quickstart |  Documentation |  Downloads |  Tutorials |  Articles

question

Upvotes
Accepted
3 1 4 4

Recommended code pattern for handling Eikon get_data timeout

Hi,

I'm a newbie to Eikon API


Is there a proscribed code pattern for handling timeouts? I have making a call to `get_data` in a loop: Each request takes about 10s to return but occasionally I get a Timeout (408/504).

I could just trap the timeout error and re-submit using following code as a starting point, but I just wondered is there an accepted/recommended code pattern to use?


thanks



    e = None
    try:
        ek.get_data(instruments, fields)
    except ek.EikonError as err:
        e = err
        # do I trap here and re-call get_data??
        raise Exception(f'Eikon error {e.code}\n{e.args}\n{e.message}')



eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apitime-out
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

Hello @john.lupton

Thank you for your participation in the forum. Is the reply below satisfactory in resolving your query?


If so please can you click the 'Accept' text next to the appropriate reply? This will guide all community members who have a similar question.

Thanks,


AHS

@john.lupton

Hi,

Please be informed that a reply has been verified as correct in answering the question, and has been marked as such.

Thanks,

AHS


1 Answer

· Write an Answer
Upvotes
Accepted
18.2k 21 13 21

Hi @john.lupton

I would add a while loop with a success flag.


ric = ['PEUP.PA']
fields = ['TR.RetireDate']

isSuccess = False

while (not isSuccess):
    try:
        df,e = ek.get_data(ric, fields)
        isSuccess = True
    except ek.EikonError as err:
        raise Exception(f'Eikon error {e.code}\n{e.args}\n{e.message}')

## the code here, already success in API call ##
print(df)



If your API call requires 10 seconds, I can assume that you require a large amount of data.

Please try to split the universe or period to reduce the amount of the data in one API call.

This would raise the success rate of the API call.


ahs.png (27.0 KiB)
icon clock
10 |1500

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.

@chavalit.jintamalit thank you for taking the time to respond. Could you clarify what do you mean by "split the universe" - I am asking for multiple fields across multiple RICs so do you mean reduce RICs or fields or both?

Thanks

Hi @john.lupton

For example:

If you request data for 2000 RIC, you may split the RIC to a smaller number.

If you request 20 RIC, but the data is 10 years of daily data, you may split the period into a smaller period.

If you request 10 RIC, but 1000 fields, you may split the field? or RIC? into a smaller list.

The point is to reduce the amount of data being transfer.

The bigger the amount of the data, the more chance that something may go wrong.

So try to balance it for your application.

Write an Answer

Hint: Notify or tag a user in this post by typing @username.

Up to 2 attachments (including images) can be used with a maximum of 512.0 KiB each and 1.0 MiB total.