Fokko commented on code in PR #7519:
URL: https://github.com/apache/iceberg/pull/7519#discussion_r1185286843
##########
python/pyiceberg/catalog/rest.py:
##########
@@ -184,37 +185,45 @@ def __init__(self, name: str, **properties: str):
name: Name to identify the catalog
properties: Properties that are passed along to the configuration
"""
- self.properties = properties
+ super().__init__(name, **properties)
self.uri = properties[URI]
+ self._session = None
+ self._create_session()
+ self._fetch_config()
self._create_session()
- super().__init__(name, **self._fetch_config(properties))
def _create_session(self) -> None:
"""Creates a request session with provided catalog configuration"""
+ if self._session:
+ self._session.close()
- self.session = Session()
+ self._session = Session()
# Sets the client side and server side SSL cert verification, if
provided as properties.
if ssl_config := self.properties.get(SSL):
if ssl_ca_bundle := ssl_config.get(CA_BUNDLE): # type: ignore
- self.session.verify = ssl_ca_bundle
+ self._session.verify = ssl_ca_bundle
if ssl_client := ssl_config.get(CLIENT): # type: ignore
if all(k in ssl_client for k in (CERT, KEY)):
- self.session.cert = (ssl_client[CERT], ssl_client[KEY])
+ self._session.cert = (ssl_client[CERT], ssl_client[KEY])
elif ssl_client_cert := ssl_client.get(CERT):
- self.session.cert = ssl_client_cert
+ self._session.cert = ssl_client_cert
# If we have credentials, but not a token, we want to fetch a token
if TOKEN not in self.properties and CREDENTIAL in self.properties:
self.properties[TOKEN] =
self._fetch_access_token(self.properties[CREDENTIAL])
# Set Auth token for subsequent calls in the session
if token := self.properties.get(TOKEN):
- self.session.headers[AUTHORIZATION_HEADER] = f"{BEARER_PREFIX}
{token}"
+ self._session.headers[AUTHORIZATION_HEADER] = f"{BEARER_PREFIX}
{token}"
# Set HTTP headers
- self.session.headers["Content-type"] = "application/json"
- self.session.headers["X-Client-Version"] = ICEBERG_REST_SPEC_VERSION
- self.session.headers["User-Agent"] = f"PyIceberg/{__version__}"
+ self._session.headers["Content-type"] = "application/json"
+ self._session.headers["X-Client-Version"] = ICEBERG_REST_SPEC_VERSION
+ self._session.headers["User-Agent"] = f"PyIceberg/{__version__}"
+
+ # Configure SigV4 Request Signing
+ if str(self.properties.get(SIGV4, False)).lower() == 'true':
Review Comment:
Fixed in https://github.com/apache/iceberg/pull/7529
--
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.
To unsubscribe, e-mail: [email protected]
For queries about this service, please contact Infrastructure at:
[email protected]
---------------------------------------------------------------------
To unsubscribe, e-mail: [email protected]
For additional commands, e-mail: [email protected]