예제 #1
0
 def test_buildProtocol(self):
     f = MemCacheClientFactory()
     addy = IPv4Address('TCP', 'ahost', 1234)
     p = f.buildProtocol(addy, timeOut=123)
     self.assertIsInstance(p, ConnectingMemCacheProtocol)
     self.assertEqual(p.persistentTimeOut, 123)
     self.assertEqual(str(p), "memcache[%s]" % addy)
예제 #2
0
 def test_buildProtocol(self):
     f = MemCacheClientFactory()
     addy = IPv4Address('TCP', 'ahost', 1234)
     p = f.buildProtocol(addy, timeOut=123)
     self.assertIsInstance(p, ConnectingMemCacheProtocol)
     self.assertEqual(p.persistentTimeOut, 123)
     self.assertEqual(str(p), "memcache[%s]" % addy)
예제 #3
0
파일: utils.py 프로젝트: aliowka/txyam
def makeTestConnections(client):
    client.factories = []
    transports = []
    for addr in client.hosts:
        factory = MemCacheClientFactory()
        client.factories.append(factory)
        proto = factory.buildProtocol(addr, timeOut=None)
        transport = StringTransportWithDisconnection()
        transport.protocol = proto
        proto.makeConnection(transport)
        transports.append(transport)
    return transports
예제 #4
0
파일: client.py 프로젝트: bmuller/txyam
    def connect(self):
        self.factories = []
        for hp in self.hosts:
            if isinstance(hp, tuple):
                host, port = hp
            elif isinstance(hp, str):
                host, port = hp, 11211
            else:
                raise InvalidHostPortError(
                    "Connection info should be either hostnames or host/port tuples"
                )
            factory = MemCacheClientFactory()
            reactor.connectTCP(host, port, factory)
            self.factories.append(factory)

        # fire callback when all connections have been established
        yield DeferredList([factory.deferred for factory in self.factories])
        returnValue(self)