本文整理匯總了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)