diff options
author | Erik Johnston <erik@matrix.org> | 2015-02-17 18:13:34 +0000 |
---|---|---|
committer | Erik Johnston <erik@matrix.org> | 2015-02-17 18:13:34 +0000 |
commit | 9371019133bf16cec163d58fe69aa701c8ca5305 (patch) | |
tree | 97638389b0f06eaa0a96a855a8ba8f33c648891b /synapse/util | |
parent | Only update destination_retry_timings if we have succeeded when retrying (diff) | |
download | synapse-9371019133bf16cec163d58fe69aa701c8ca5305.tar.xz |
Try to only back off if we think we failed to connect to the remote
Diffstat (limited to '')
-rw-r--r-- | synapse/util/retryutils.py | 10 |
1 files changed, 8 insertions, 2 deletions
diff --git a/synapse/util/retryutils.py b/synapse/util/retryutils.py index 888b7ef2e9..d190100c8c 100644 --- a/synapse/util/retryutils.py +++ b/synapse/util/retryutils.py @@ -15,6 +15,8 @@ from twisted.internet import defer +from synapse.api.errors import CodeMessageException + import logging @@ -67,7 +69,7 @@ def get_retry_limiter(destination, clock, store, **kwargs): class RetryDestinationLimiter(object): def __init__(self, destination, clock, store, retry_interval, min_retry_interval=20000, max_retry_interval=60 * 60 * 1000, - multiplier_retry_interval=2): + multiplier_retry_interval=2,): self.clock = clock self.store = store self.destination = destination @@ -87,7 +89,11 @@ class RetryDestinationLimiter(object): failure.value ) - if exc_type is None and exc_val is None and exc_tb is None: + valid_err_code = False + if exc_type is CodeMessageException: + valid_err_code = 0 <= exc_val.code < 500 + + if exc_type is None or valid_err_code: # We connected successfully. if not self.retry_interval: return |