Skip to content
This repository has been archived by the owner on Apr 26, 2024. It is now read-only.

Commit

Permalink
Merge pull request #1650 from matrix-org/erikj/respect_ratelimited
Browse files Browse the repository at this point in the history
Correctly handle 500's and 429 on federation
  • Loading branch information
erikjohnston authored Nov 24, 2016
2 parents 7e03f9a + 11bfe43 commit 9192e59
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 1 deletion.
7 changes: 7 additions & 0 deletions synapse/federation/transaction_queue.py
Original file line number Diff line number Diff line change
Expand Up @@ -462,6 +462,13 @@ def json_data_cb():
code = e.code
response = e.response

if e.code == 429 or 500 <= e.code:
logger.info(
"TX [%s] {%s} got %d response",
destination, txn_id, code
)
raise e

logger.info(
"TX [%s] {%s} got %d response",
destination, txn_id, code
Expand Down
2 changes: 1 addition & 1 deletion synapse/util/retryutils.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,7 +123,7 @@ def __enter__(self):
def __exit__(self, exc_type, exc_val, exc_tb):
valid_err_code = False
if exc_type is not None and issubclass(exc_type, CodeMessageException):
valid_err_code = 0 <= exc_val.code < 500
valid_err_code = exc_val.code != 429 and 0 <= exc_val.code < 500

if exc_type is None or valid_err_code:
# We connected successfully.
Expand Down

0 comments on commit 9192e59

Please sign in to comment.