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
1 1 0 0

Getting this error in Python Script: eikon.eikonError.EikonError: Error code 408 | Request timeout occured

I'm using the Eikon Data Api in a Python script that makes a get_news_headlines call every x minutes/hours. About 50% of the time I get this error: eikon.eikonError.EikonError: Error code 408 | Request timeout occured.

Looking for any ideas on how to fix this?

while True:
      try:
            headlines = ek.get_news_headlines(query='Language:LEN AND Source:RTRS',20,datetime.datetime.now().utcnow() - datetime.timedelta(minutes=x), datetime.datetime.now().utcnow())

            time.sleep(x)
          
      except (ek.EikonError):
      print("Error")
           
eikoneikon-data-apipythonrefinitiv-dataplatform-eikonworkspaceworkspace-data-apierror-408
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.

@kp123

Hi,

Thank you for your participation in the forum. Is the reply below satisfactory in answering your question? If yes please click the 'Accept' text next to the most appropriate reply.

This will guide all community members who have a similar question. Otherwise please post again offering further insight into your question.

Thanks,

AHS

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
4.3k 2 4 5

Hi,

time.sleep() has a none visible effect: it's freezing all the thread, including the code that's sending the request and waiting for the response.

If you pause your code with time.sleep() function for a long time (more than several seconds), you shoudl replace with one another solution (x should be given in seconds):

from datetime import datetime, timedelta 
from threading import Event 
timer_event = Event() 

while True: 
    try: 
        headline = ek.get_news_headlines(query='Language:LEN AND Source:RTRS', count=20, date_from=datetime.now().utcnow() - timedelta(minutes=x), date_to=datetime.now().utcnow())
        timer_event.wait(timeout=x*60)
    except(ek.EikonError): 
        print("Error") 

or :

from datetime import datetime, timedelta 
import asyncio 

while True:
    try: 
        headline = ek.get_news_headlines(query='Language:LEN AND Source:RTRS',                                          count=20,                                          date_from=datetime.now().utcnow() - timedelta(minutes=x),                                          date_to=datetime.now().utcnow())
        asyncio.get_event_loop().run_until_complete(asyncio.sleep(x))
    except(ek.EikonError):
        print("Error")



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.

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.