endpoint.py 文件源码

python
阅读 24 收藏 0 点赞 0 评论 0

项目:txamqp 作者: txamqp 项目源码 文件源码
def connect(self, protocol_factory):
        """
        Connect to the C{protocolFactory} to the AMQP broker specified by the
        URI of this endpoint.

        @param protocol_factory: An L{AMQFactory} building L{AMQClient} objects.
        @return: A L{Deferred} that results in an L{AMQClient} upon successful
            connection otherwise a L{Failure} wrapping L{ConnectError} or
            L{NoProtocol <twisted.internet.error.NoProtocol>}.
        """
        # XXX Since AMQClient requires these parameters at __init__ time, we
        #     need to override them in the provided factory.
        protocol_factory.set_vhost(self._vhost)
        protocol_factory.set_heartbeat(self._heartbeat)

        description = "tcp:{}:{}:timeout={}".format(
            self._host, self._port, self._timeout)
        endpoint = clientFromString(self._reactor, description)

        deferred = endpoint.connect(protocol_factory)
        return deferred.addCallback(self._authenticate)
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号