本文整理汇总了Python中gunicorn.workers.SUPPORTED_WORKERS属性的典型用法代码示例。如果您正苦于以下问题:Python workers.SUPPORTED_WORKERS属性的具体用法?Python workers.SUPPORTED_WORKERS怎么用?Python workers.SUPPORTED_WORKERS使用的例子?那么, 这里精选的属性代码示例或许可以为您提供帮助。您也可以进一步了解该属性所在类gunicorn.workers
的用法示例。
在下文中一共展示了workers.SUPPORTED_WORKERS属性的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: load_class
# 需要导入模块: from gunicorn import workers [as 别名]
# 或者: from gunicorn.workers import SUPPORTED_WORKERS [as 别名]
def load_class(uri):
components = uri.split('.')
if len(components) == 1 and uri in SUPPORTED_WORKERS:
components = SUPPORTED_WORKERS[uri].split(".")
klass = components.pop(-1)
try:
mod = import_module('.'.join(components))
except:
exc = traceback.format_exc()
msg = "class uri %r invalid or not found: \n\n[%s]"
raise RuntimeError(msg % (uri, exc))
return getattr(mod, klass)
示例2: load_class
# 需要导入模块: from gunicorn import workers [as 别名]
# 或者: from gunicorn.workers import SUPPORTED_WORKERS [as 别名]
def load_class(uri, default="gunicorn.workers.sync.SyncWorker",
section="gunicorn.workers"):
if inspect.isclass(uri):
return uri
if uri.startswith("egg:"):
# uses entry points
entry_str = uri.split("egg:")[1]
try:
dist, name = entry_str.rsplit("#", 1)
except ValueError:
dist = entry_str
name = default
try:
return pkg_resources.load_entry_point(dist, section, name)
except:
exc = traceback.format_exc()
msg = "class uri %r invalid or not found: \n\n[%s]"
raise RuntimeError(msg % (uri, exc))
else:
components = uri.split('.')
if len(components) == 1:
while True:
if uri.startswith("#"):
uri = uri[1:]
if uri in SUPPORTED_WORKERS:
components = SUPPORTED_WORKERS[uri].split(".")
break
try:
return pkg_resources.load_entry_point("gunicorn",
section, uri)
except:
exc = traceback.format_exc()
msg = "class uri %r invalid or not found: \n\n[%s]"
raise RuntimeError(msg % (uri, exc))
klass = components.pop(-1)
try:
mod = import_module('.'.join(components))
except:
exc = traceback.format_exc()
msg = "class uri %r invalid or not found: \n\n[%s]"
raise RuntimeError(msg % (uri, exc))
return getattr(mod, klass)