diff --git a/python/xoscar/utils.py b/python/xoscar/utils.py index 5c6cb851..4d44c57e 100644 --- a/python/xoscar/utils.py +++ b/python/xoscar/utils.py @@ -19,11 +19,11 @@ import dataclasses import functools import importlib +import importlib.util as importlib_utils import inspect import io import logging import os -import pkgutil import random import socket import sys @@ -267,7 +267,7 @@ def add_load_handler(self, func: Callable): self._on_loads.append(func) return func - if pkgutil.find_loader(prefix_name) is not None: + if importlib_utils.find_spec(prefix_name) is not None: return LazyModule() elif placeholder: return ModulePlaceholder(prefix_name)