當前位置: 首頁>>代碼示例>>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;未經允許,請勿轉載。