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


Python asyncio.ZMQEventLoop方法代码示例

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


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

示例1: main

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ZMQEventLoop [as 别名]
def main():
    app = Sanic(__name__)
    app.blueprint(ACCOUNTS_BP)
    app.blueprint(ASSETS_BP)
    app.blueprint(AUTH_BP)
    app.blueprint(ERRORS_BP)
    app.blueprint(HOLDINGS_BP)
    app.blueprint(OFFERS_BP)

    load_config(app)
    zmq = ZMQEventLoop()
    asyncio.set_event_loop(zmq)
    server = app.create_server(
        host=app.config.HOST, port=app.config.PORT, debug=app.config.DEBUG)
    loop = asyncio.get_event_loop()
    asyncio.ensure_future(server)
    asyncio.ensure_future(open_connections(app))
    signal(SIGINT, lambda s, f: loop.close())
    try:
        loop.run_forever()
    except KeyboardInterrupt:
        close_connections(app)
        loop.stop() 
开发者ID:hyperledger,项目名称:sawtooth-marketplace,代码行数:25,代码来源:main.py

示例2: setUp

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ZMQEventLoop [as 别名]
def setUp(self):
        if asyncio is None:
            raise SkipTest()
        self.loop = zaio.ZMQEventLoop()
        asyncio.set_event_loop(self.loop)
        super(TestAsyncIOSocket, self).setUp() 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:8,代码来源:_test_asyncio.py

示例3: start_asyncio_and_zmq

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ZMQEventLoop [as 别名]
def start_asyncio_and_zmq(debug_asyncio=False):
    """ Init asyncio and ZMQ. Starts a daemon thread in which the asyncio loops run.
    :return: a ZMQ context and a Thread object (as a tuple)
    """
    loop = ZMQEventLoop()
    asyncio.set_event_loop(loop)
    if debug_asyncio:
        loop.set_debug(True)
    zmq_context = Context()

    t = threading.Thread(target=_run_asyncio, args=(loop, zmq_context), daemon=True)
    t.start()

    return zmq_context, t 
开发者ID:UCL-INGI,项目名称:INGInious,代码行数:16,代码来源:arch_helper.py

示例4: setUp

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ZMQEventLoop [as 别名]
def setUp(self):
        if asyncio is None:
            raise SkipTest()
        self.loop = zaio.ZMQEventLoop()
        asyncio.set_event_loop(self.loop)
        super().setUp() 
开发者ID:luckystarufo,项目名称:pySINDy,代码行数:8,代码来源:_test_asyncio.py

示例5: main

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ZMQEventLoop [as 别名]
def main():
    loop = ZMQEventLoop()
    asyncio.set_event_loop(loop)

    try:
        opts = parse_args(sys.argv[1:])

        init_console_logging(verbose_level=opts.verbose)

        validator_url = opts.connect
        if "tcp://" not in validator_url:
            validator_url = "tcp://" + validator_url
        messenger = Messenger(validator_url)

        database = Database(
            opts.db_host,
            opts.db_port,
            opts.db_name,
            opts.db_user,
            opts.db_password,
            loop)

        try:
            host, port = opts.bind.split(":")
            port = int(port)
        except ValueError:
            print("Unable to parse binding {}: Must be in the format"
                  " host:port".format(opts.bind))
            sys.exit(1)

        start_rest_api(host, port, messenger, database)
    except Exception as err:  # pylint: disable=broad-except
        LOGGER.exception(err)
        sys.exit(1)
    finally:
        database.disconnect()
        messenger.close_validator_connection() 
开发者ID:hyperledger,项目名称:education-sawtooth-simple-supply,代码行数:39,代码来源:main.py

示例6: main

# 需要导入模块: from zmq import asyncio [as 别名]
# 或者: from zmq.asyncio import ZMQEventLoop [as 别名]
def main():
    LOGGER.info('Starting Clinic Rest API server...')
    # CORS(app)

    app.blueprint(CLINICS_BP)
    app.blueprint(DOCTORS_BP)
    app.blueprint(PATIENTS_BP)
    app.blueprint(CLAIMS_BP)
    app.blueprint(CLAIM_DETAILS_BP)
    app.blueprint(LAB_TESTS_BP)
    app.blueprint(PULSE_BP)
    app.blueprint(CLIENTS_BP)
    app.blueprint(LABS_BP)
    app.blueprint(INSURANCES_BP)
    app.blueprint(CONTRACT_BP)
    app.blueprint(PAYMENT_BP)
    # app.blueprint(OFFERS_BP)

    load_config(app)
    zmq = ZMQEventLoop()
    asyncio.set_event_loop(zmq)
    server = app.create_server(
        host=app.config.HOST, port=app.config.PORT, debug=app.config.DEBUG, return_asyncio_server=True)
    loop = asyncio.get_event_loop()
    asyncio.ensure_future(open_connections(app))
    asyncio.ensure_future(server)
    signal(SIGINT, lambda s, f: loop.close())
    try:
        LOGGER.info('Clinic Rest API server starting')
        loop.run_forever()
    except KeyboardInterrupt:
        LOGGER.info('Clinic Rest API started interrupted')
        close_connections(app)
        loop.stop() 
开发者ID:hyperledger-labs,项目名称:sawtooth-healthcare,代码行数:36,代码来源:main.py


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