|
@ -49,16 +49,18 @@ class ConnectionManager(object): |
|
|
self._s = requests.Session() |
|
|
self._s = requests.Session() |
|
|
self._s.auth = lambda x: x # don't let requests add auth headers |
|
|
self._s.auth = lambda x: x # don't let requests add auth headers |
|
|
|
|
|
|
|
|
# retry once to reset connection with Keycloak after tomcat's ConnectionTimeout |
|
|
|
|
|
# see https://github.com/marcospereirampj/python-keycloak/issues/36 |
|
|
|
|
|
for protocol in ('https://', 'http://'): |
|
|
|
|
|
adapter = HTTPAdapter(max_retries=1) |
|
|
|
|
|
# adds POST to retry whitelist |
|
|
|
|
|
allowed_methods = set(adapter.max_retries.allowed_methods) |
|
|
|
|
|
allowed_methods.add('POST') |
|
|
|
|
|
adapter.max_retries.allowed_methods = frozenset(allowed_methods) |
|
|
|
|
|
|
|
|
|
|
|
self._s.mount(protocol, adapter) |
|
|
|
|
|
|
|
|
self._s.get(self.base_url) |
|
|
|
|
|
|
|
|
|
|
|
# # retry once to reset connection with Keycloak after tomcat's ConnectionTimeout |
|
|
|
|
|
# # see https://github.com/marcospereirampj/python-keycloak/issues/36 |
|
|
|
|
|
# for protocol in ('https://', 'http://'): |
|
|
|
|
|
# adapter = HTTPAdapter(max_retries=1) |
|
|
|
|
|
# # adds POST to retry whitelist |
|
|
|
|
|
# allowed_methods = set(adapter.max_retries.allowed_methods) |
|
|
|
|
|
# allowed_methods.add('POST') |
|
|
|
|
|
# adapter.max_retries.allowed_methods = frozenset(allowed_methods) |
|
|
|
|
|
|
|
|
|
|
|
# self._s.mount(protocol, adapter) |
|
|
|
|
|
|
|
|
def __del__(self): |
|
|
def __del__(self): |
|
|
self._s.close() |
|
|
self._s.close() |
|
|