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


Python ClientFactory.forProtocol方法代码示例

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


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

示例1: _initClient

# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import forProtocol [as 别名]
 def _initClient(self, clientConnString):
     """
     Инициализация клиента
     :type clientConnString: str строка подключения для clientFromString
     :return : defer.Deferred с аргументом self.clientProtocol
     """
     clientEndpoint = clientFromString(self.reactor, clientConnString)
     saveProtocol = lambda p: save(self, 'clientProtocol', p)  # given protocol
     self.clientFactory = ClientFactory.forProtocol(lambda: AMP(locator=self.locator))
     return clientEndpoint.connect(self.clientFactory).addCallback(saveProtocol).addCallback(self.setClientProtocol)
开发者ID:musius,项目名称:collaboration,代码行数:12,代码来源:core.py

示例2: _connectClient

# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import forProtocol [as 别名]
 def _connectClient(self, d2):
     """
     Подключиться к серверу
     :param d2: defer.Deferred вызываемый при connectionLost
     :return: defer.Deferred с результатом подключения (инициализированный протокол ClientProtocolStub)
     """
     factory = ClientFactory.forProtocol(ClientProtocolStub)
     factory.onConnectionLost = d2
     return clientFromString(self.reactor, b"tcp:host=localhost:port={0}".format(self.serverPort.getHost().port)) \
         .connect(factory)
开发者ID:musius,项目名称:collaboration,代码行数:12,代码来源:baseTest2.py

示例3: listening

# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import forProtocol [as 别名]
        def listening(port):
            msg("Listening on %r" % (port.getHost(),))
            endpoint = self.endpoints.client(reactor, port.getHost())

            client = endpoint.connect(
                ClientFactory.forProtocol(lambda: clientProtocol))
            def disconnect(proto):
                msg("About to disconnect %r" % (proto,))
                proto.transport.loseConnection()
            client.addCallback(disconnect)
            client.addErrback(lostConnectionDeferred.errback)
            return lostConnectionDeferred
开发者ID:0004c,项目名称:VTK,代码行数:14,代码来源:connectionmixins.py

示例4: setUp

# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import forProtocol [as 别名]
 def setUp(self):
     self.client_factory = ClientFactory.forProtocol(DummyClientProtocol)
     self.server_factory = ServerFactory.forProtocol(DummyServerProtocol)
开发者ID:jerith,项目名称:txfake,代码行数:5,代码来源:test_fake_connection.py

示例5: main

# 需要导入模块: from twisted.internet.protocol import ClientFactory [as 别名]
# 或者: from twisted.internet.protocol.ClientFactory import forProtocol [as 别名]
def main(reactor):
    ep = UNIXClientEndpoint(reactor, '/var/run/postgresql/.s.PGSQL.5432')
    fact = ClientFactory.forProtocol(PostgresProtocol)
    proto = yield ep.connect(fact)
    # for i in range(5000):
    res = yield proto.runQuery('SELECT * from entries limit 5')
开发者ID:tehasdf,项目名称:txpg2,代码行数:8,代码来源:run.py


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