mirror of
https://github.com/frappe/gunicorn.git
synced 2026-01-14 11:09:11 +08:00
parent
8ab090aafb
commit
eb73681181
@ -23,6 +23,7 @@ import socket
|
|||||||
import sys
|
import sys
|
||||||
import textwrap
|
import textwrap
|
||||||
import time
|
import time
|
||||||
|
import traceback
|
||||||
import inspect
|
import inspect
|
||||||
import errno
|
import errno
|
||||||
import warnings
|
import warnings
|
||||||
@ -118,7 +119,12 @@ def load_class(uri, default="sync", section="gunicorn.workers"):
|
|||||||
dist = entry_str
|
dist = entry_str
|
||||||
name = default
|
name = default
|
||||||
|
|
||||||
return pkg_resources.load_entry_point(dist, section, name)
|
try:
|
||||||
|
return pkg_resources.load_entry_point(dist, section, name)
|
||||||
|
except:
|
||||||
|
exc = traceback.format_exc()
|
||||||
|
raise RuntimeError("class uri %r invalid or not found: \n\n[%s]" % (uri,
|
||||||
|
exc))
|
||||||
else:
|
else:
|
||||||
components = uri.split('.')
|
components = uri.split('.')
|
||||||
if len(components) == 1:
|
if len(components) == 1:
|
||||||
@ -128,11 +134,19 @@ def load_class(uri, default="sync", section="gunicorn.workers"):
|
|||||||
|
|
||||||
return pkg_resources.load_entry_point("gunicorn",
|
return pkg_resources.load_entry_point("gunicorn",
|
||||||
section, uri)
|
section, uri)
|
||||||
except ImportError as e:
|
except:
|
||||||
raise RuntimeError("class uri invalid or not found: " +
|
exc = traceback.format_exc()
|
||||||
"[%s]" % str(e))
|
raise RuntimeError("class uri %r invalid or not found: \n\n[%s]" % (uri,
|
||||||
|
exc))
|
||||||
|
|
||||||
klass = components.pop(-1)
|
klass = components.pop(-1)
|
||||||
mod = __import__('.'.join(components))
|
try:
|
||||||
|
mod = __import__('.'.join(components))
|
||||||
|
except:
|
||||||
|
exc = traceback.format_exc()
|
||||||
|
raise RuntimeError("class uri %r invalid or not found: \n\n[%s]" % (uri,
|
||||||
|
exc))
|
||||||
|
|
||||||
for comp in components[1:]:
|
for comp in components[1:]:
|
||||||
mod = getattr(mod, comp)
|
mod = getattr(mod, comp)
|
||||||
return getattr(mod, klass)
|
return getattr(mod, klass)
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user