Skip to content

Commit aa913e9

Browse files
committed
aadarsh-st/SK-2521- Resolved comments
1 parent f6d3f8b commit aa913e9

File tree

2 files changed

+8
-12
lines changed

2 files changed

+8
-12
lines changed

skyflow/vault/controller/_connections.py

Lines changed: 5 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,12 +30,11 @@ def invoke(self, request: InvokeConnectionRequest):
3030
log_info(SkyflowMessages.Info.INVOKE_CONNECTION_TRIGGERED.value, self.__vault_client.get_logger())
3131

3232
try:
33-
response = session.send(invoke_connection_request)
34-
try:
35-
invoke_connection_response = parse_invoke_connection_response(response)
36-
return invoke_connection_response
37-
finally:
38-
response.close()
33+
with session:
34+
response = session.send(invoke_connection_request)
35+
with response:
36+
invoke_connection_response = parse_invoke_connection_response(response)
37+
return invoke_connection_response
3938
except Exception as e:
4039
log_error_log(SkyflowMessages.ErrorLogs.INVOKE_CONNECTION_REQUEST_REJECTED.value, self.__vault_client.get_logger())
4140
if isinstance(e, SkyflowError): raise e

skyflow/vault/controller/_detect.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -79,9 +79,8 @@ def __poll_for_processed_file(self, run_id, max_wait_time=64):
7979
current_wait_time = next_wait_time
8080
time.sleep(wait_time)
8181
elif status == 'SUCCESS' or status == 'FAILED':
82-
# Retrieve the response data before closing the HTTP response
83-
result = response
84-
return result
82+
# Create a copy of the response data before closing
83+
return response
8584
finally:
8685
http_response.close()
8786
except Exception as e:
@@ -289,9 +288,7 @@ def deidentify_file(self, request: DeidentifyFileRequest):
289288
file_extension = self._get_file_extension(file_name) if file_name else None
290289

291290
# Track if we need to close the file (only if it was opened from file_path)
292-
file_needs_closing = False
293-
if hasattr(request.file, 'file_path') and request.file.file_path is not None:
294-
file_needs_closing = True
291+
file_needs_closing = hasattr(request.file, 'file_path') and request.file.file_path is not None
295292

296293
try:
297294
file_content = file_obj.read()

0 commit comments

Comments
 (0)