当前位置: 首页>>代码示例>>Python>>正文


Python workers.SUPPORTED_WORKERS属性代码示例

本文整理汇总了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) 
开发者ID:encode,项目名称:uvicorn,代码行数:15,代码来源:main.py

示例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) 
开发者ID:RoseOu,项目名称:flasky,代码行数:49,代码来源:util.py


注:本文中的gunicorn.workers.SUPPORTED_WORKERS属性示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。