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


Python zmq.eventloop方法代码示例

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


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

示例1: test_recv_json_cancelled

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import eventloop [as 别名]
def test_recv_json_cancelled(self):
        @gen.coroutine
        def test():
            a, b = self.create_bound_pair(zmq.PUSH, zmq.PULL)
            f = b.recv_json()
            assert not f.done()
            f.cancel()
            # cycle eventloop to allow cancel events to fire
            yield gen.sleep(0)
            obj = dict(a=5)
            yield a.send_json(obj)
            with pytest.raises(future.CancelledError):
                recvd = yield f
            assert f.done()
            # give it a chance to incorrectly consume the event
            events = yield b.poll(timeout=5)
            assert events
            yield gen.sleep(0)
            # make sure cancelled recv didn't eat up event
            recvd = yield gen.with_timeout(timedelta(seconds=5), b.recv_json())
            assert recvd == obj
        self.loop.run_sync(test) 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:24,代码来源:test_future.py

示例2: enter_eventloop

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import eventloop [as 别名]
def enter_eventloop(self):
        """enter eventloop"""
        self.log.info("entering eventloop")
        # restore default_int_handler
        signal(SIGINT, default_int_handler)
        while self.eventloop is not None:
            try:
                self.eventloop(self)
            except KeyboardInterrupt:
                # Ctrl-C shouldn't crash the kernel
                self.log.error("KeyboardInterrupt caught in kernel")
                continue
            else:
                # eventloop exited cleanly, this means we should stop (right?)
                self.eventloop = None
                break
        self.log.info("exiting eventloop") 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:19,代码来源:ipkernel.py

示例3: test_eventloop

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import eventloop [as 别名]
def test_eventloop(self):
        """test eventloop imports"""
        try:
            import tornado
        except ImportError:
            pytest.skip('requires tornado')
        import zmq.eventloop
        from zmq.eventloop import ioloop
        from zmq.eventloop import zmqstream 
开发者ID:birforce,项目名称:vnpy_crypto,代码行数:11,代码来源:test_imports.py

示例4: run_application

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import eventloop [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

示例5: _eventloop_changed

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import eventloop [as 别名]
def _eventloop_changed(self, name, old, new):
        """schedule call to eventloop from IOLoop"""
        loop = ioloop.IOLoop.instance()
        loop.add_timeout(time.time()+0.1, self.enter_eventloop) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:6,代码来源:ipkernel.py

示例6: do_one_iteration

# 需要导入模块: import zmq [as 别名]
# 或者: from zmq import eventloop [as 别名]
def do_one_iteration(self):
        """step eventloop just once"""
        InteractiveShell.set_instance(self.shell)
        if self.control_stream:
            self.control_stream.flush()
        for stream in self.shell_streams:
            # handle at most one request per iteration
            stream.flush(zmq.POLLIN, 1)
            stream.flush(zmq.POLLOUT) 
开发者ID:ktraunmueller,项目名称:Computable,代码行数:11,代码来源:ipkernel.py


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