Skip to content
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
14 changes: 12 additions & 2 deletions adlfs/utils.py
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
import inspect
from typing import Optional

try:
Expand Down Expand Up @@ -81,5 +82,14 @@ async def close_credential(file_obj):
Implements asynchronous closure of credentials for
AzureBlobFile objects
"""
if not isinstance(file_obj.credential, (type(None), str)):
await file_obj.credential.close()
credential = getattr(file_obj, "credential", None)
if credential is None or isinstance(credential, str):
return

close_method = getattr(credential, "close", None)
if not callable(close_method):
return

close_result = close_method()
if inspect.isawaitable(close_result):
await close_result