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


Python uvloop.install方法代码示例

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


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

示例1: main

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def main(ctx: click.Context, config_path: Path, debug: bool) -> None:

    cfg = load_config(config_path, debug)
    multiprocessing.set_start_method('spawn')

    if ctx.invoked_subcommand is None:
        cfg['manager']['pid-file'].write_text(str(os.getpid()))
        log_sockpath = Path(f'/tmp/backend.ai/ipc/manager-logger-{os.getpid()}.sock')
        log_sockpath.parent.mkdir(parents=True, exist_ok=True)
        log_endpoint = f'ipc://{log_sockpath}'
        try:
            logger = Logger(cfg['logging'], is_master=True, log_endpoint=log_endpoint)
            with logger:
                ns = cfg['etcd']['namespace']
                setproctitle(f"backend.ai: manager {ns}")
                log.info('Backend.AI Gateway {0}', __version__)
                log.info('runtime: {0}', env_info())
                log_config = logging.getLogger('ai.backend.gateway.config')
                log_config.debug('debug mode enabled.')

                if cfg['manager']['event-loop'] == 'uvloop':
                    import uvloop
                    uvloop.install()
                    log.info('Using uvloop as the event loop backend')
                try:
                    aiotools.start_server(server_main_logwrapper,
                                          num_workers=cfg['manager']['num-proc'],
                                          args=(cfg, log_endpoint))
                finally:
                    log.info('terminated.')
        finally:
            if cfg['manager']['pid-file'].is_file():
                # check is_file() to prevent deleting /dev/null!
                cfg['manager']['pid-file'].unlink()
    else:
        # Click is going to invoke a subcommand.
        pass 
开发者ID:lablup,项目名称:backend.ai-manager,代码行数:39,代码来源:server.py

示例2: _new_run

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def _new_run(func, *args, backend=None, backend_options=None):
    if backend is None:
        backend = os.getenv("PURERPC_BACKEND", "asyncio")
    log.info("Selected {} backend".format(backend))
    if backend == "uvloop":
        import uvloop
        uvloop.install()
        backend = "asyncio"
    return _anyio_run(func, *args, backend=backend, backend_options=backend_options) 
开发者ID:standy66,项目名称:purerpc,代码行数:11,代码来源:anyio_monkeypatch.py

示例3: execute

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def execute(argv: Sequence[str] = None):
    """Entrypoint."""
    parser = ArgumentParser()
    parser.prog += " start"
    get_settings = init_argument_parser(parser)
    args = parser.parse_args(argv)
    settings = get_settings(args)
    common_config(settings)

    # set ledger to read only if explicitely specified
    settings["ledger.read_only"] = settings.get("read_only_ledger", False)

    # Support WEBHOOK_URL environment variable
    webhook_url = os.environ.get("WEBHOOK_URL")
    if webhook_url:
        webhook_urls = list(settings.get("admin.webhook_urls") or [])
        webhook_urls.append(webhook_url)
        settings["admin.webhook_urls"] = webhook_urls

    # Create the Conductor instance
    context_builder = DefaultContextBuilder(settings)
    conductor = Conductor(context_builder)

    # Run the application
    if uvloop:
        uvloop.install()
        print("uvloop installed")
    run_loop(start_app(conductor), shutdown_app(conductor)) 
开发者ID:hyperledger,项目名称:aries-cloudagent-python,代码行数:30,代码来源:start.py

示例4: setUp

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def setUp(self):
        uvloop.install() 
开发者ID:formony,项目名称:ton_client,代码行数:4,代码来源:test_asyncio.py

示例5: serve_grpclib_uvloop

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def serve_grpclib_uvloop():
    import uvloop
    uvloop.install()

    asyncio.run(_grpclib_server()) 
开发者ID:vmagamedov,项目名称:grpclib,代码行数:7,代码来源:bench.py

示例6: serve_grpcio_uvloop

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def serve_grpcio_uvloop():
    import uvloop
    uvloop.install()

    from _reference.server import serve

    try:
        asyncio.run(serve())
    except KeyboardInterrupt:
        pass 
开发者ID:vmagamedov,项目名称:grpclib,代码行数:12,代码来源:bench.py

示例7: serve_aiohttp_uvloop

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def serve_aiohttp_uvloop():
    import uvloop
    uvloop.install()

    _aiohttp_server() 
开发者ID:vmagamedov,项目名称:grpclib,代码行数:7,代码来源:bench.py

示例8: main

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def main() -> None:
    app = init_app()
    app_settings = app['config']['app']

    {%- if cookiecutter.use_uvloop == 'y' %}
    uvloop.install()
    {%- endif %}
    web.run_app(
        app,
        host=app_settings['host'],
        port=app_settings['port'],
    ) 
开发者ID:aio-libs,项目名称:create-aio-app,代码行数:14,代码来源:__main__.py

示例9: main

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def main():
    try:
        # noinspection PyUnresolvedReferences
        import uvloop

        logger.debug("Setting up with uvloop.")
        uvloop.install()
    except ImportError:
        pass

    bot = ModmailBot()
    bot.run() 
开发者ID:kyb3r,项目名称:modmail,代码行数:14,代码来源:bot.py

示例10: main

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def main():
    if uvloop is not None:
        uvloop.install()
    asyncio.run(async_main()) 
开发者ID:Chia-Network,项目名称:chia-blockchain,代码行数:6,代码来源:start_timelord.py

示例11: run_service

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def run_service(*args, **kwargs):
    if uvloop is not None:
        uvloop.install()
    # TODO: use asyncio.run instead
    # for now, we use `run_until_complete` as `asyncio.run` blocks on RPC server not exiting
    if 1:
        return asyncio.get_event_loop().run_until_complete(
            async_run_service(*args, **kwargs)
        )
    else:
        return asyncio.run(async_run_service(*args, **kwargs)) 
开发者ID:Chia-Network,项目名称:chia-blockchain,代码行数:13,代码来源:start_service.py

示例12: main

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def main():
    if uvloop is not None:
        uvloop.install()
    asyncio.run(start_websocket_server()) 
开发者ID:Chia-Network,项目名称:chia-blockchain,代码行数:6,代码来源:start_wallet.py

示例13: __init__

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def __init__(self, debug=False):
        self.debug = debug
        if not self.debug:
            uvloop.install()

        self.loop = asyncio.get_event_loop()
        self._prepare()
        self.proxyman = ProxyMan(self.listen_host) 
开发者ID:Ehco1996,项目名称:aioshadowsocks,代码行数:10,代码来源:app.py

示例14: init_uvloop

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def init_uvloop():
    import uvloop
    uvloop.install() 
开发者ID:DevAlone,项目名称:proxy_py,代码行数:5,代码来源:main.py

示例15: setup_asyncio

# 需要导入模块: import uvloop [as 别名]
# 或者: from uvloop import install [as 别名]
def setup_asyncio(config: util.config.Config) -> asyncio.AbstractEventLoop:
    """Returns a new asyncio event loop with settings from the given config."""

    asyncio_config: util.config.AsyncIOConfig = config["asyncio"]

    if sys.platform == "win32":
        # Force ProactorEventLoop on Windows for subprocess support
        policy = asyncio.WindowsProactorEventLoopPolicy()
        asyncio.set_event_loop_policy(policy)
    elif not asyncio_config["disable_uvloop"]:
        # Initialize uvloop if available
        try:
            # noinspection PyUnresolvedReferences
            import uvloop

            uvloop.install()
            log.info("Using uvloop event loop")
        except ImportError:
            pass

    loop = asyncio.new_event_loop()

    if asyncio_config["debug"]:
        log.info("Enabling asyncio debug mode")
        loop.set_debug(True)

    return loop 
开发者ID:kdrag0n,项目名称:pyrobud,代码行数:29,代码来源:launch.py


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