Exemplo n.º 1
0
        def do_setup(_res):
            self.factory = RedisClientFactory()
            reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
            d = self.factory.deferred

            def cannot_connect(_res):
                raise unittest.SkipTest('Cannot connect to Redis.')

            d.addErrback(cannot_connect)
            return d
Exemplo n.º 2
0
 def do_setup(_res):
     self.factory = RedisClientFactory()
     reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
     d = self.factory.deferred
     def cannot_connect(_res):
         raise unittest.SkipTest('Cannot connect to Redis.')
     d.addErrback(cannot_connect)
     return d
Exemplo n.º 3
0
class TestFactory(CommandsTestBase):
    def setUp(self):
        d = CommandsTestBase.setUp(self)

        def do_setup(_res):
            self.factory = RedisClientFactory()
            reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
            d = self.factory.deferred

            def cannot_connect(_res):
                raise unittest.SkipTest('Cannot connect to Redis.')

            d.addErrback(cannot_connect)
            return d

        d.addCallback(do_setup)
        return d

    def tearDown(self):
        CommandsTestBase.tearDown(self)
        self.factory.continueTrying = 0
        self.factory.stopTrying()
        if self.factory.client:
            self.factory.client.setTimeout(None)
            self.factory.client.transport.loseConnection()

    @defer.inlineCallbacks
    def test_reconnect(self):
        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)

        # teardown the connection
        self.factory.client.transport.loseConnection()

        # wait until reconnected
        a = yield self.factory.deferred

        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)

    timeout = 4
Exemplo n.º 4
0
class TestFactory(unittest.TestCase):
    @defer.inlineCallbacks
    def setUp(self):
        self.factory = RedisClientFactory()
        reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
        yield self.factory.deferred

    def tearDown(self):
        self.factory.stopTrying()
        self.factory.client.transport.loseConnection()

    @defer.inlineCallbacks
    def test_reconnect(self):
        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)

        # teardown the connection
        self.factory.client.transport.loseConnection()

        # wait until reconnected
        a = yield self.factory.deferred

        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)
Exemplo n.º 5
0
class TestFactory(CommandsTestBase):
    def setUp(self):
        d = CommandsTestBase.setUp(self)
        def do_setup(_res):
            self.factory = RedisClientFactory()
            reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
            d = self.factory.deferred
            def cannot_connect(_res):
                raise unittest.SkipTest('Cannot connect to Redis.')
            d.addErrback(cannot_connect)
            return d
        d.addCallback(do_setup)
        return d

    def tearDown(self):
        CommandsTestBase.tearDown(self)
        self.factory.continueTrying = 0
        self.factory.stopTrying()
        if self.factory.client:
            self.factory.client.setTimeout(None)
            self.factory.client.transport.loseConnection()

    @defer.inlineCallbacks
    def test_reconnect(self):
        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)

        # teardown the connection
        self.factory.client.transport.loseConnection()

        # wait until reconnected
        a = yield self.factory.deferred

        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)
    timeout = 4
Exemplo n.º 6
0
class TestFactory(unittest.TestCase):
    @defer.inlineCallbacks
    def setUp(self):
        self.factory = RedisClientFactory()
        reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
        yield self.factory.deferred

    def tearDown(self):
        self.factory.stopTrying()
        self.factory.client.transport.loseConnection()

    @defer.inlineCallbacks
    def test_reconnect(self):
        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)

        # teardown the connection
        self.factory.client.transport.loseConnection()

        # wait until reconnected
        a = yield self.factory.deferred

        a = yield self.factory.client.info()
        self.assertTrue('uptime_in_days' in a)
Exemplo n.º 7
0
 def setUp(self):
     self.factory = RedisClientFactory()
     reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
     yield self.factory.deferred
Exemplo n.º 8
0
 def clientConnectionFailed(self, connector, reason):
     print "WARNING: Redis Command Connection Failed to Reconnect. Probably still dropping messages!"
     RedisClientFactory.clientConnectionFailed(self, connector, reason)        
Exemplo n.º 9
0
 def clientConnectionLost(self, connector, reason):
     print "WARNING: Redis Command Connection Lost. Probably dropping messages!"
     RedisClientFactory.clientConnectionLost(self, connector, reason)
Exemplo n.º 10
0
 def buildProtocol(self, addr):
     print "Connected to redis (Command Connection)."
     protocol = RedisClientFactory.buildProtocol(self, addr)
     self.services.redis = protocol
     return protocol
Exemplo n.º 11
0
 def __init__(self, services, *args, **kwargs):
     RedisClientFactory.__init__(self, *args, **kwargs)
     self.services = services
Exemplo n.º 12
0
 def setUp(self):
     self.factory = RedisClientFactory()
     reactor.connectTCP(REDIS_HOST, REDIS_PORT, self.factory)
     yield self.factory.deferred