Hey,
I'm using some API calls, in a fixed rate timer script. In my script I've configured quite a short time out, but the script seems to get stuck at the API call and then just seems to be aborted when that fixed rate times out.
I don't mind if it time out as the idea is we should put this into a retry queue, but as it just aborts it doesn't failover and retry continue the script. Is there a way to force the client to give up after the timeout and then we continue.
My timer script is as below:
We pass an object containing the data, url, method etc. into the queue it polls from.
client = system.net.httpClient(timeout=3000)
def alarmQueueTimerScript():
logger.debug("Sending Alarm Transmisson Start")
nextItem = alarmDeque.poll(5000, TimeUnit.MILLISECONDS)
logger.info("Alarm Queue, next item: " + str(nextItem))
if nextItem:
if nextItem["method"] == "post":
try:
response = client.post(nextItem["url"], data=nextItem["data"], headers=nextItem["headers"])
except Exception as e:
logger.error("Fail to send alarm data! Appending to retry queue...")
logger.debug("Fail to send: {a}, to URL: {b}".format(a = str(data), b = str(url)))
logger.trace("Fail to send because of {a}".format(a = str(e)))
......
Whenever it gets to the line about client.post
it halts there and doesn't continue any further, my loop is at a fixed rate of 5000 ms, I'm expecting it to give up before then and continue the function, but it never does.
I'm testing without connection to the end point to test the failure conditions.