Many readtimeout errors today (07-Jul-2020)

ganeshv02
Hi @sujith @rakeshr

Today my program faced too many ReadTimeOut errors when querying for last traded price. Was there a problem? Despite using try/except block - the program halted. I am not sure why. Can you or anyone in this forum give some thoughts?

def get_ltp(kite, trading_exchange, contract_name):
while True:
try:
temp_list = [trading_exchange + ':' + contract_name]
ltp = kite.ltp([temp_list])
temp_list = trading_exchange + ':' + contract_name # convert temp_list to string
ltp = ltp[temp_list]['last_price']
logging.info("LTP of the contract is: %s", ltp)
return float(ltp)
except exceptions.KiteException as e:
logging.info("Exception occurred while getting ltp: \n %s", e.args)
continue
  • rakeshr
    @ganeshv02
    We haven't observed any such error at our end. Anyhow, we will log today's data to see, if any.
  • rakeshr
    @ganeshv02
    We logged LTP and Quote request-response for almost the whole day and weren't able to encounter anything unusual.
  • ganeshv02
    ganeshv02 edited July 2020
    ok thanks @rakeshr. I will investigate on my end and let you know if it recurs.

    To catch the read timeout exception is below good enough?
    def get_ltp(kite, trading_exchange, contract_name):
    while True:
    try:
    temp_list = [trading_exchange + ':' + contract_name]
    ltp = kite.ltp([temp_list])
    temp_list = trading_exchange + ':' + contract_name # convert temp_list to string
    ltp = ltp[temp_list]['last_price']
    logging.info("LTP of the contract is: %s", ltp)
    return float(ltp)
    except requests.exceptions.ReadTimeout as e:
    logging.exception("Timeout Error - while getting ltp: \n %s", e)
    logging.info("Retrying")
    time.sleep(1)
    continue

  • rakeshr
    @ganeshv02
    except requests.exceptions.ReadTimeout as e:
    Yeah, it's correct.
  • ganeshv02
    Thanks so much @rakeshr
Sign In or Register to comment.