Ejemplo n.º 1
0
def start_stop_one(handler=None):
    if not handler:
        handler = eventlet_handler.SequentialEventletHandler()
    handler.start()
    try:
        yield handler
    finally:
        handler.stop()
Ejemplo n.º 2
0
    def test_timeout_raising(self):
        handler = eventlet_handler.SequentialEventletHandler()

        @raises(handler.timeout_exception)
        def raise_it():
            raise handler.timeout_exception("This is a timeout")

        raise_it()
Ejemplo n.º 3
0
    def test_get_with_no_block(self):
        handler = eventlet_handler.SequentialEventletHandler()

        with start_stop_one(handler):
            r = handler.async_result()

            with pytest.raises(handler.timeout_exception):
                r.get(block=False)
            r.set(1)
            assert r.get() == 1
Ejemplo n.º 4
0
    def test_get_with_no_block(self):
        handler = eventlet_handler.SequentialEventletHandler()

        @raises(handler.timeout_exception)
        def test_no_block(r):
            r.get(block=False)

        with start_stop_one(handler):
            r = handler.async_result()
            test_no_block(r)
            r.set(1)
            self.assertEqual(1, r.get())
Ejemplo n.º 5
0
 def _lazy_initialize(self):
     if not self.client:
         hosts = _parse_hosts(self.config.remote_db_hosts)
         _handler = eventlet.SequentialEventletHandler()
         _retry = retry.KazooRetry(max_tries=CLIENT_CONNECTION_RETRIES,
                                   delay=0.5,
                                   backoff=2,
                                   sleep_func=_handler.sleep_func)
         self.client = client.KazooClient(hosts=hosts,
                                          handler=_handler,
                                          connection_retry=_retry)
         self.client.start()
         self.client.ensure_path(ROOT_NS)
Ejemplo n.º 6
0
    def test_timeout_raising(self):
        handler = eventlet_handler.SequentialEventletHandler()

        with pytest.raises(handler.timeout_exception):
            raise handler.timeout_exception("This is a timeout")
Ejemplo n.º 7
0
 def _makeOne(self, *args):
     return eventlet_handler.SequentialEventletHandler(*args)