Below is my code in bottle. I am using uWSGI with the gevent loop. From the time of the request, I need to return false if the entire request is taking longer than 90 milliseconds. I dont get how to use gevent to timeout after 90ms. The blocking codes less less than 2 ms. Its the redis calls that are the issue. Under no load or little load...entire requests takes under 20ms. Under severe load, redis calls can take longer...I need to time out if longer. So, from the first redis call, timeout if taking longer than 90 ms the return. If less than 90ms, calculate the remainder. E.g. if call one takes 60 ms then I have 30 ms for call two. If call 2 is taking longer then 30 ms then timeout.
@post('/test')
def test():
#START THE TIMER
#SOME BLOCKING CODE
#MAKE A REDIS CALL AND SERVICE OTHER REQUESTS
jt = [gevent.spawn(redis_call)]
gevent.joinall(jt)
#SOME BLOCKING CODE
#MAKE A REDIS CALL AND SERVICE OTHER REQUESTS
jt = [gevent.spawn(redis_call)]
gevent.joinall(jt)
if total_time<.09:
yield "passed"
else:
yield "failed"