Skip to content

Commit 2124fe0

Browse files
explicitly close response object
Signed-off-by: varun-edachali-dbx <varun.edachali@databricks.com>
1 parent 25596e7 commit 2124fe0

File tree

1 file changed

+5
-3
lines changed

1 file changed

+5
-3
lines changed

src/databricks/sql/backend/sea/utils/http_client.py

Lines changed: 5 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -189,17 +189,16 @@ def _make_request(
189189

190190
logger.debug(f"Making {method} request to {path}")
191191

192+
response = None
192193
try:
193194
response = self.session.request(
194195
method=method.upper(),
195196
url=f"{self.base_url}{path}",
196197
json=data, # requests handles JSON encoding automatically
197198
headers=headers,
198199
)
199-
200-
response.raise_for_status() # This will raise an HTTPError for non-2xx responses
200+
response.raise_for_status()
201201
return response.json()
202-
203202
except MaxRetryDurationError as e:
204203
# MaxRetryDurationError is raised directly by DatabricksRetryPolicy
205204
# when duration limits are exceeded
@@ -218,6 +217,9 @@ def _make_request(
218217
logger.error(f"SEA HTTP request failed with exception: {e}")
219218
error_message = f"Error during request to server. {e}"
220219
raise RequestError(error_message, None, e)
220+
finally:
221+
if response is not None:
222+
response.close()
221223

222224
def _get_command_type_from_path(self, path: str, method: str) -> CommandType:
223225
"""

0 commit comments

Comments
 (0)