imp module is deprecated in v3 so in place of it using importlib
@@ -24,7 +24,7 @@ import time
import os
import pdb
import stat
-import imp
+import importlib
import types
import _apache
try:
@@ -581,8 +581,6 @@ def import_module(module_name, autoreload=1, log=0, path=None):
# nlehuen: this is a big lock, we'll have to refine it later to get better performance.
# For now, we'll concentrate on thread-safety.
- imp.acquire_lock()
- try:
# (Re)import
if module_name in sys.modules:
@@ -632,19 +630,7 @@ def import_module(module_name, autoreload=1, log=0, path=None):
_apache.log_error(s, APLOG_NOTICE)
parent = None
- parts = module_name.split('.')
- for i in range(len(parts)):
- f, p, d = imp.find_module(parts[i], path)
- try:
- mname = ".".join(parts[:i+1])
- module = imp.load_module(mname, f, p, d)
- if parent:
- setattr(parent,parts[i],module)
- parent = module
- finally:
- if f: f.close()
- if hasattr(module, "__path__"):
- path = module.__path__
+ module = importlib.import_module(module_name)
if mtime == 0:
mtime = module_mtime(module)
@@ -652,8 +638,6 @@ def import_module(module_name, autoreload=1, log=0, path=None):
module.__mtime__ = mtime
return module
- finally:
- imp.release_lock()
def module_mtime(module):
"""Get modification time of module"""
