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-apipythonworkspacerefinitiv-dataplatform-eikonworkspace-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.

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