diff --git a/matrix_client/api.py b/matrix_client/api.py index 4ff54f69..05ba58af 100644 --- a/matrix_client/api.py +++ b/matrix_client/api.py @@ -667,6 +667,7 @@ def _send(self, method, path, content=None, query_params={}, headers={}, raise MatrixHttpLibError(e, method, endpoint) if response.status_code == 429: + waittime = self.default_429_wait_ms / 1000 try: waittime = response.json()['retry_after_ms'] / 1000 except KeyError: @@ -674,9 +675,8 @@ def _send(self, method, path, content=None, query_params={}, headers={}, errordata = json.loads(response.json()['error']) waittime = errordata['retry_after_ms'] / 1000 except KeyError: - waittime = self.default_429_wait_ms / 1000 - finally: - sleep(waittime) + pass + sleep(waittime) else: break