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


Python profiler.ProfilerMiddleware方法代码示例

本文整理汇总了Python中werkzeug.contrib.profiler.ProfilerMiddleware方法的典型用法代码示例。如果您正苦于以下问题:Python profiler.ProfilerMiddleware方法的具体用法?Python profiler.ProfilerMiddleware怎么用?Python profiler.ProfilerMiddleware使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在werkzeug.contrib.profiler的用法示例。


在下文中一共展示了profiler.ProfilerMiddleware方法的5个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: make_action

# 需要导入模块: from werkzeug.contrib import profiler [as 别名]
# 或者: from werkzeug.contrib.profiler import ProfilerMiddleware [as 别名]
def make_action(app_factory, hostname='localhost', port=5000,
                threaded=False, processes=1, stream=None,
                sort_by=('time', 'calls'), restrictions=()):
    """Return a new callback for :mod:`werkzeug.script` that starts a local
    server with the profiler enabled.

    ::

        from werkzeug.contrib import profiler
        action_profile = profiler.make_action(make_app)
    """
    def action(hostname=('h', hostname), port=('p', port),
               threaded=threaded, processes=processes):
        """Start a new development server."""
        from werkzeug.serving import run_simple
        app = ProfilerMiddleware(app_factory(), stream, sort_by, restrictions)
        run_simple(hostname, port, app, False, None, threaded, processes)
    return action 
开发者ID:jpush,项目名称:jbox,代码行数:20,代码来源:profiler.py

示例2: start_shipyard

# 需要导入模块: from werkzeug.contrib import profiler [as 别名]
# 或者: from werkzeug.contrib.profiler import ProfilerMiddleware [as 别名]
def start_shipyard(default_config_files=None):
    # Trigger configuration resolution.
    config.parse_args(args=[], default_config_files=default_config_files)

    LoggingConfig(
        level=CONF.logging.log_level,
        named_levels=CONF.logging.named_log_levels
    ).setup_logging()

    # Setup the RBAC policy enforcer
    policy.policy_engine = policy.ShipyardPolicy()
    policy.policy_engine.register_policy()

    # Start the API
    if CONF.base.profiler:
        LOG.warning("Profiler ENABLED. Expect significant "
                    "performance overhead.")
        return ProfilerMiddleware(
            api.start_api(),
            profile_dir="/tmp/profiles")  # nosec
    else:
        return api.start_api() 
开发者ID:airshipit,项目名称:shipyard,代码行数:24,代码来源:start_shipyard.py

示例3: profile

# 需要导入模块: from werkzeug.contrib import profiler [as 别名]
# 或者: from werkzeug.contrib.profiler import ProfilerMiddleware [as 别名]
def profile(length=25, profile_dir=None):
    """Start the application under the code profiler."""
    from werkzeug.contrib.profiler import ProfilerMiddleware
    app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[length],
                                      profile_dir=profile_dir)
    app.run() 
开发者ID:CircleCI-Public,项目名称:circleci-demo-python-flask,代码行数:8,代码来源:manage.py

示例4: run

# 需要导入模块: from werkzeug.contrib import profiler [as 别名]
# 或者: from werkzeug.contrib.profiler import ProfilerMiddleware [as 别名]
def run():
    fcrepo = create_app(env.app_globals.config['application'])
    fcrepo.wsgi_app = ProfilerMiddleware(fcrepo.wsgi_app, **options)
    fcrepo.config['PROFILE'] = True
    fcrepo.run(debug = True) 
开发者ID:scossu,项目名称:lakesuperior,代码行数:7,代码来源:profiler.py

示例5: create_app

# 需要导入模块: from werkzeug.contrib import profiler [as 别名]
# 或者: from werkzeug.contrib.profiler import ProfilerMiddleware [as 别名]
def create_app(**config_overrides):
    """
    Creates a flask application with the desired configuration settings
    and connects it to the database.
    """
    app = Flask(__name__)

    # Initialize logging
    _configure_logging()

    # Initialize configuration
    app.config.from_object("teamserver.config")
    app.config["MODE"] = MODE

    app.config["MONGODB_SETTINGS"] = {"db": DB_NAME, "host": DB_HOST, "port": DB_PORT}
    if DB_USER and DB_PASS:
        app.config["MONGODB_SETTINGS"]["username"] = DB_USER
        app.config["MONGODB_SETTINGS"]["password"] = DB_PASS

    app.config["CELERY_BROKER_URL"] = CELERY_BROKER_URL
    app.config["CELERY_RESULT_BACKEND"] = CELERY_RESULT_BACKEND

    # Override configuration options
    app.config.update(config_overrides)

    # Initialize DEBUG
    if MODE.upper() == "DEBUG":
        # Enable debug logging
        app.logger.setLevel(logging.DEBUG)

        # Enable profiling
        from werkzeug.contrib.profiler import ProfilerMiddleware

        app.config["PROFILE"] = True
        app.wsgi_app = ProfilerMiddleware(app.wsgi_app, restrictions=[50], profile_dir=PROFILE_DIR)

        # Enable mongodb debug toolbar
        from flask_debugtoolbar import DebugToolbarExtension

        app.config["DEBUG_TB_PANELS"] = ["flask_mongoengine.panels.MongoDebugPanel"]
        app.debug_toolbar = DebugToolbarExtension(app)
    else:
        app.logger.setLevel(logging.WARNING)

    # Initialize the database
    try:
        DB.init_app(app)
    except MongoEngineConnectionError as conn_err:
        print(conn_err)
        sys.exit("Could not connect to database.")

    # Import endpoints
    from teamserver.router import API

    app.register_blueprint(API)

    app.logger.info(f"Initialized Arsenal Teamserver [{MODE}]")
    return app 
开发者ID:KCarretto,项目名称:Arsenal,代码行数:60,代码来源:__init__.py


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