Skip to content

Commit

Permalink
fix
Browse files Browse the repository at this point in the history
Signed-off-by: Aylei <[email protected]>
  • Loading branch information
aylei committed Dec 20, 2024
1 parent c5202e0 commit be60a18
Showing 1 changed file with 10 additions and 9 deletions.
19 changes: 10 additions & 9 deletions sky/adaptors/common.py
Original file line number Diff line number Diff line change
Expand Up @@ -31,15 +31,16 @@ def load_module(self):
# Avoid extra imports when multiple threads try to import the same
# module. The overhead is minor since import can only run in serial
# due to GIL even in multi-threaded environments.
if self._module is None:
try:
self._module = importlib.import_module(self._module_name)
if self._set_loggers is not None:
self._set_loggers()
except ImportError as e:
if self._import_error_message is not None:
raise ImportError(self._import_error_message) from e
raise
with self._lock:
if self._module is None:
try:
self._module = importlib.import_module(self._module_name)
if self._set_loggers is not None:
self._set_loggers()
except ImportError as e:
if self._import_error_message is not None:
raise ImportError(self._import_error_message) from e
raise
return self._module

def __getattr__(self, name: str) -> Any:
Expand Down

0 comments on commit be60a18

Please sign in to comment.