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