From 09baff1912d87d451740cf0ece1a286367910dc5 Mon Sep 17 00:00:00 2001 From: cariaso <cariaso@gmail.com> Date: Mon, 12 Jun 2017 05:43:04 +0900 Subject: [PATCH] Detect, warn and retry on nonce error (#165) Retry on nonce errors since these can be caused by temporary cache connection errors. --- mwclient/client.py | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/mwclient/client.py b/mwclient/client.py index 98af048..97b8b2b 100644 --- a/mwclient/client.py +++ b/mwclient/client.py @@ -307,6 +307,13 @@ class Site(object): sleeper.sleep() return False + # cope with https://phabricator.wikimedia.org/T106066 + if (info['error'].get('code') == u'mwoauth-invalid-authorization' and + 'Nonce already used' in info['error'].get('info')): + log.warning('retrying due to nonce error https://phabricator.wikimedia.org/T106066') + sleeper.sleep() + return False + if 'query' in info['error']: # Semantic Mediawiki does not follow the standard error format raise errors.APIError(None, info['error']['query'], kwargs) -- GitLab