0
0
Fork 1
mirror of https://mau.dev/maunium/synapse.git synced 2024-11-16 15:01:23 +01:00

Use min and not max to set an upper bound on retry interval

This commit is contained in:
Erik Johnston 2015-11-20 09:34:58 +00:00
parent f9d9bd6aa0
commit 2f2bbb4d06

View file

@ -190,11 +190,11 @@ class MatrixFederationHttpClient(object):
if retries_left and not timeout: if retries_left and not timeout:
if long_retries: if long_retries:
delay = 4 ** (MAX_LONG_RETRIES + 1 - retries_left) delay = 4 ** (MAX_LONG_RETRIES + 1 - retries_left)
delay = max(delay, 60) delay = min(delay, 60)
delay *= random.uniform(0.8, 1.4) delay *= random.uniform(0.8, 1.4)
else: else:
delay = 0.5 * 2 ** (MAX_SHORT_RETRIES - retries_left) delay = 0.5 * 2 ** (MAX_SHORT_RETRIES - retries_left)
delay = max(delay, 2) delay = min(delay, 2)
delay *= random.uniform(0.8, 1.4) delay *= random.uniform(0.8, 1.4)
yield sleep(delay) yield sleep(delay)