Don't drop tokens if refresh failed due to a connection issue

This commit is contained in:
norohind 2021-12-07 15:37:09 +03:00
parent cc8eaaa04c
commit 3571e7b070
Signed by: norohind
GPG Key ID: 01C3BECC26FB59E1

View File

@ -1,3 +1,5 @@
import requests
from . import model
from . import utils
from . import exceptions
@ -146,9 +148,15 @@ class CAPIAuthorizer:
msg['description'] = 'Token were successfully updated'
return msg
except requests.ConnectionError as e:
logger.warning(f'Connection problem on refresh for {state!r}', exc_info=e)
msg['status'] = 'error'
msg['description'] = 'Connection Error'
raise exceptions.RefreshFail(msg['description'], msg['status'], state)
except Exception as e:
# probably here something don't work
logger.warning(f'Fail on refreshing token for {state}, row:{row}')
logger.warning(f'Fail on refreshing token for {state!r}, row:{row}', exc_info=e)
msg['status'] = 'error'
self.model.increment_refresh_tries(state)