Skip to content

Commit a2dd94a

Browse files
committed
updated as per PR's copilot autofixes
1 parent 9c0cff1 commit a2dd94a

File tree

2 files changed

+26
-4
lines changed

2 files changed

+26
-4
lines changed

application_sdk/clients/azure/azure.py

Lines changed: 23 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -249,4 +249,26 @@ def __enter__(self):
249249

250250
def __exit__(self, exc_type, exc_val, exc_tb):
251251
"""Context manager exit."""
252-
asyncio.create_task(self.close())
252+
# Note: This is a synchronous context manager.
253+
# For proper async cleanup, use the async context manager instead.
254+
# This method is kept for backward compatibility but doesn't guarantee cleanup.
255+
logger.warning(
256+
"Using synchronous context manager. For proper async cleanup, "
257+
"use 'async with AzureClient() as client:' instead."
258+
)
259+
# Schedule cleanup but don't wait for it
260+
try:
261+
loop = asyncio.get_event_loop()
262+
if loop.is_running():
263+
loop.create_task(self.close())
264+
except RuntimeError:
265+
# No event loop running, can't schedule async cleanup
266+
logger.warning("No event loop running, async cleanup not possible")
267+
268+
async def __aenter__(self):
269+
"""Async context manager entry."""
270+
return self
271+
272+
async def __aexit__(self, exc_type, exc_val, exc_tb):
273+
"""Async context manager exit."""
274+
await self.close()

application_sdk/clients/azure/azure_utils.py

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,9 +38,9 @@ def parse_azure_url(url: str) -> Dict[str, str]:
3838
hostname = parsed.netloc.lower()
3939
service_type = None
4040

41-
if ".blob.core.windows.net" in hostname:
41+
if hostname.endswith(".blob.core.windows.net"):
4242
service_type = "blob"
43-
elif ".dfs.core.windows.net" in hostname:
43+
elif hostname.endswith(".dfs.core.windows.net"):
4444
service_type = "datalake"
4545
else:
4646
service_type = "unknown"
@@ -298,4 +298,4 @@ def format_azure_error_message(error: Exception, context: Optional[str] = None)
298298

299299
except Exception as e:
300300
logger.error(f"Failed to format Azure error message: {str(e)}")
301-
return f"Azure Error: {str(error)}"
301+
return f"Azure Error: {str(error)}"

0 commit comments

Comments
 (0)