當前位置: 首頁>>代碼示例>>Python>>正文


Python ioloop.install方法代碼示例

本文整理匯總了Python中zmq.eventloop.ioloop.install方法的典型用法代碼示例。如果您正苦於以下問題:Python ioloop.install方法的具體用法?Python ioloop.install怎麽用?Python ioloop.install使用的例子?那麽, 這裏精選的方法代碼示例或許可以為您提供幫助。您也可以進一步了解該方法所在zmq.eventloop.ioloop的用法示例。


在下文中一共展示了ioloop.install方法的2個代碼示例,這些例子默認根據受歡迎程度排序。您可以為喜歡或者感覺有用的代碼點讚,您的評價將有助於係統推薦出更棒的Python代碼示例。

示例1: run_application

# 需要導入模塊: from zmq.eventloop import ioloop [as 別名]
# 或者: from zmq.eventloop.ioloop import install [as 別名]
def run_application(options, instance_name):
  from zmq.eventloop import ioloop
  ioloop.install()

  application = WebSocketGatewayApplication(options, instance_name)

  server = tornado.httpserver.HTTPServer(application)
  server.listen(options.port)

  try:
    tornado.ioloop.IOLoop.instance().start()
  except KeyboardInterrupt:
    application.clean_up() 
開發者ID:bitex-coin,項目名稱:backend,代碼行數:15,代碼來源:main.py

示例2: __init__

# 需要導入模塊: from zmq.eventloop import ioloop [as 別名]
# 或者: from zmq.eventloop.ioloop import install [as 別名]
def __init__(self, config, driver_info, driver):
    # Clone config so we can update it.
    config = json.loads(json.dumps(config))

    self._config = config
    self._exiting = False
    self._engine_id = str(uuid.uuid4())
    self._wire = WireProtocol(self._engine_id, config["key"], config["signature_scheme"])

    connection = config["transport"] + "://" + config["ip"]

    def bind(socket, port):
      if port <= 0:
        return socket.bind_to_random_port(connection)
      else:
        socket.bind("%s:%s" % (connection, port))
      return port

    def wrap_with_deserialization(fn):
      def accept(wire_msg):
        return fn(*self._wire.deserialize_wire_msg(wire_msg))

      return accept

    ## Initialize:
    ioloop.install()

    ctx = zmq.Context()
    self._heartbeat_socket = ctx.socket(zmq.REP)
    config["hb_port"] = bind(self._heartbeat_socket, config["hb_port"])

    # IOPub/Sub: also called SubSocketChannel in IPython sources
    self._iopub_socket = ctx.socket(zmq.PUB)
    config["iopub_port"] = bind(self._iopub_socket, config["iopub_port"])
    iopub_stream = zmqstream.ZMQStream(self._iopub_socket)
    iopub_stream.on_recv(wrap_with_deserialization(self._iopub_handler))
    iopub = OutgoingStream(self._wire, iopub_stream)

    self._control_socket = ctx.socket(zmq.ROUTER)
    config["control_port"] = bind(self._control_socket, config["control_port"])
    control_stream = zmqstream.ZMQStream(self._control_socket)
    control_stream.on_recv(wrap_with_deserialization(self._control_handler))

    self._stdin_socket = ctx.socket(zmq.ROUTER)
    config["stdin_port"] = bind(self._stdin_socket, config["stdin_port"])
    stdin_stream = zmqstream.ZMQStream(self._stdin_socket)
    stdin_stream.on_recv(wrap_with_deserialization(self._stdin_handler))

    self._shell_socket = ctx.socket(zmq.ROUTER)
    config["shell_port"] = bind(self._shell_socket, config["shell_port"])
    shell_stream = zmqstream.ZMQStream(self._shell_socket)
    shell = OutgoingStream(self._wire, shell_stream)
    shell_stream.on_recv(wrap_with_deserialization(self._shell_handler))

    self._shell_handler_impl = ShellHandler(self._engine_id, iopub, shell, driver_info, driver) 
開發者ID:tensorlang,項目名稱:tensorlang,代碼行數:57,代碼來源:jupyter_kernel.py


注:本文中的zmq.eventloop.ioloop.install方法示例由純淨天空整理自Github/MSDocs等開源代碼及文檔管理平台,相關代碼片段篩選自各路編程大神貢獻的開源項目,源碼版權歸原作者所有,傳播和使用請參考對應項目的License;未經允許,請勿轉載。