Commit d91d3221 authored by Martin Bauer's avatar Martin Bauer
Browse files

cpujit: try second time if module could not be loaded

parent 6373c03a
...@@ -401,9 +401,19 @@ def create_module_boilerplate_code(module_name, names): ...@@ -401,9 +401,19 @@ def create_module_boilerplate_code(module_name, names):
def load_kernel_from_file(module_name, function_name, path): def load_kernel_from_file(module_name, function_name, path):
from importlib.util import spec_from_file_location, module_from_spec from importlib.util import spec_from_file_location, module_from_spec
spec = spec_from_file_location(name=module_name, location=path) try:
mod = module_from_spec(spec) spec = spec_from_file_location(name=module_name, location=path)
spec.loader.exec_module(mod) mod = module_from_spec(spec)
except ImportError:
import time
import warnings
warnings.warn("Could not load " + path + ", trying on more time...")
spec = spec_from_file_location(name=module_name, location=path)
mod = module_from_spec(spec)
return getattr(mod, function_name) return getattr(mod, function_name)
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment