Error Code 2504- Occurs at random times in code, how is this error caused and how is it solved?

Best Answer

  • Hi,

    As you mention, this error could occur randomly.

    A way to protect your code is to catch the exception then retry your request after a delay.

    Ex:

    from threading import Event
    timer = Event()
    ...
    while True:
    try:
    ts = ek.get_timeseries(...)
    break
    except ek.EikonError as err:
    if err.err_code != 2504:
    # request failed with other reason than 2504 error code
    break
    # let's retry after a delay
    timer.wait(1)

    (timer.wait() is better than time.sleep())

Answers

  • Hi,

    I'm having the same issue. I'm retrying a few times, and still seeing either "Error code 2504 | UDF Core request failed. Gateway Time-out" or "Error code 500 | Backend error. 500 Internal Server Error". Would you know the reason why this occurs?

    Also, could you please elaborate on why timer.wait() is preferable? Would switching from time.sleep() to timer.wait() help alleviate these issues?

    Thank you,

    Shashank

  • Hi, Can you please explain why this is better? (timer.wait() is better than time.sleep())

    I am not currently multitreading but having similar issue.