コード例 #1
0
ファイル: test_factory.py プロジェクト: alberist/txyam
 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)