GoogleCloudPlatform/cloud-sql-python-connector

Use one client session per connector

enocom opened this issue · 0 comments

Currently, we use one client session per instance. Instead, we should use one client session per connector.

def _client_session(self) -> aiohttp.ClientSession:
if self.__client_session is None:
headers = {
"x-goog-api-client": self._user_agent_string,
"User-Agent": self._user_agent_string,
"Content-Type": "application/json",
}
if self._quota_project:
headers["x-goog-user-project"] = self._quota_project
self.__client_session = aiohttp.ClientSession(headers=headers)
return self.__client_session