use import_module instead of our own hack to import the module

This commit is contained in:
benoitc 2013-12-26 11:51:18 +01:00
parent a397d90774
commit fdccb61616

View File

@ -136,15 +136,14 @@ def load_class(uri, default="gunicorn.workers.sync.SyncWorker",
exc)) exc))
klass = components.pop(-1) klass = components.pop(-1)
try: try:
mod = __import__('.'.join(components)) mod = import_module('.'.join(components))
except: except:
exc = traceback.format_exc() exc = traceback.format_exc()
raise RuntimeError("class uri %r invalid or not found: \n\n[%s]" % (uri, raise RuntimeError(
exc)) "class uri %r invalid or not found: \n\n[%s]" %
(uri, exc))
for comp in components[1:]:
mod = getattr(mod, comp)
return getattr(mod, klass) return getattr(mod, klass)