QPS timeout was badly calculated

timedelta microseconds is just the microseconds part of the timedelta
object not the elapsed time in microseconds.

I've change to use the total_seconds method to get all the elapsed time
in seconds and transform to miliseconds.
This commit is contained in:
Mario de Frutos 2016-12-23 11:40:30 +01:00
parent 23a2de0321
commit 80b23c62c3

View File

@ -55,7 +55,8 @@ class QPSService:
def retry(self, first_request_time, retry_count): def retry(self, first_request_time, retry_count):
elapsed = datetime.now() - first_request_time elapsed = datetime.now() - first_request_time
if elapsed.microseconds > (self._retry_timeout * 1000.0 * 1000.0): elapsed_miliseconds = (elapsed.total_seconds() * 1000.0)
if elapsed_miliseconds > (self._retry_timeout * 1000.0):
raise TimeoutException() raise TimeoutException()
# inverse qps * (1.5 ^ i) is an increased sleep time of 1.5x per # inverse qps * (1.5 ^ i) is an increased sleep time of 1.5x per