Browse Source

Also retry on POST

hotfix/merge
Guillaume Troupel 5 years ago
parent
commit
1e806554b5
  1. 11
      keycloak/connection.py

11
keycloak/connection.py

@ -47,10 +47,17 @@ class ConnectionManager(object):
self._timeout = timeout
self._verify = verify
self._s = requests.Session()
# retry once to reset connection with Keycloak after tomcat's ConnectionTimeout
# see https://github.com/marcospereirampj/python-keycloak/issues/36
self._s.mount('https://', HTTPAdapter(max_retries=1))
self._s.mount('http://', HTTPAdapter(max_retries=1))
for protocol in ('https://', 'http://'):
adapter = HTTPAdapter(max_retries=1)
# adds POST to retry whitelist
method_whitelist = set(adapter.max_retries.method_whitelist)
method_whitelist.add('POST')
adapter.max_retries.method_whitelist = frozenset(method_whitelist)
self._s.mount(protocol, adapter)
@property
def base_url(self):

Loading…
Cancel
Save