Skip to content

Commit

Permalink
Detect, warn and retry on nonce error (#165)
Browse files Browse the repository at this point in the history
Retry on nonce errors since these can be caused by temporary cache connection errors.
  • Loading branch information
cariaso authored and danmichaelo committed Jun 11, 2017
1 parent 2f7151a commit 09baff1
Showing 1 changed file with 7 additions and 0 deletions.
7 changes: 7 additions & 0 deletions mwclient/client.py
Original file line number Diff line number Diff line change
Expand Up @@ -307,6 +307,13 @@ def handle_api_result(self, info, kwargs=None, sleeper=None):
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)
Expand Down

0 comments on commit 09baff1

Please sign in to comment.