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


Python AMQClient.connectionMade方法代码示例

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


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

示例1: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     AMQClient.connectionMade(self)
     # Authenticate.
     assert self.factory is not None
     deferred = self.start({"LOGIN": self.factory.user,
                            "PASSWORD": self.factory.password})
     deferred.addCallbacks(self._authenticated, self._authentication_failed)
开发者ID:vigilo,项目名称:connector,代码行数:9,代码来源:amqp.py

示例2: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
    def connectionMade(self):
        """
        Hook called when the connection is made; we'll use this to perform
        exchange setup, etc.
        """
        try:
            connectionInfo = self.factory.connectionInfo
            set_keepalive(self.transport.socket, connectionInfo.amqpconnectionheartbeat)
            AMQClient.connectionMade(self)
            log.debug('Made initial connection to message broker')
            self._connected = False
            # Authenticate
            try:
                yield self.start({'LOGIN':connectionInfo.user, 'PASSWORD':connectionInfo.password})
                self.factory.onAuthenticated(True)
                log.debug('Successfully authenticated as %s' % connectionInfo.user)
            except Exception as e:
                log.warn("Error authenticating to %s as %s" % (connectionInfo.host, connectionInfo.user))
                self.factory.onAuthenticated(e.args[0])
                return
            # Get a channel
            self.chan = yield self.get_channel()
            self._connected = True
            # Initialize the queues
            yield self.begin_listening()

            # Call back our deferred
            self.factory.onConnectionMade(self)
            # Flush any messages that have been sent before now
            yield self.send()
            returnValue(None)
        except Exception:
            log.exception("Unable to connect")
开发者ID:jhanson,项目名称:zenoss-protocols,代码行数:35,代码来源:amqp.py

示例3: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     AMQClient.connectionMade(self)
     yield self.authenticate(self.vumi_options['username'],
                             self.vumi_options['password'])
     # authentication was successful
     log.msg("Got an authenticated connection")
     yield self.connected_callback(self)
开发者ID:AndrewCvekl,项目名称:vumi,代码行数:9,代码来源:service.py

示例4: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     """Called when a connection has been made."""
     AMQClient.connectionMade(self)
     # Flag that this protocol is not connected yet.
     self.connected = False
     
     # Authenticate.
     deferred = self.authenticate(self.factory.user, self.factory.password)
     deferred.addCallback(self._authenticated)
     deferred.addErrback(self._authentication_failed)
开发者ID:sanyaade,项目名称:carrot,代码行数:12,代码来源:amqp.py

示例5: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     AMQClient.connectionMade(self)
     # set that we are not connected
     # since we should authenticate and open channels
     self.connected = False
     self.log.debug('go authentication %r'%self.factory.user)
     d = self.authenticate(self.factory.user, self.factory.password)
     d.addCallback(self._authenticated)
     d.addErrback(self._error)
     return d
开发者ID:cybergrind,项目名称:txamqp_ext,代码行数:12,代码来源:protocol.py

示例6: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
    def connectionMade(self):
        """
        Add this protocol as a consumer of log events.
        """
        AMQClient.connectionMade(self)

        def eb(failure):
            log.err(failure)
            self.transport.loseConnection()

        d = self.gotConnection()
        d.addErrback(eb)
开发者ID:mailgun,项目名称:udplog,代码行数:14,代码来源:rabbitmq.py

示例7: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     """
     authenticate and start the Node 
     """
     AMQClient.connectionMade(self)
     username = self.factory.username
     password = self.factory.password
     # authentication should happen automatically, and fail asap
     # XXX need to know how it can fail still
     d = self.authenticate(username, password)
     d.addCallback(self._auth_result)
     d.addErrback(self._auth_fail)
开发者ID:deldotdr,项目名称:anion,代码行数:14,代码来源:messaging.py

示例8: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
    def connectionMade(self):
        """Called when a connection has been made."""
        AMQClient.connectionMade(self)

        # Flag that this protocol is not connected yet.
        self.connected = False

        self.consumer_tags = {}

        # Authenticate.
        deferred = self.start({"LOGIN": self.factory.user, "PASSWORD": self.factory.password})
        deferred.addCallback(self._authenticated)
        deferred.addErrback(self._authentication_failed)
开发者ID:BlocklandGlass-Archive,项目名称:Glass-PyServer,代码行数:15,代码来源:amqp_helpers.py

示例9: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
    def connectionMade(self):
        """Called when a connection has been made."""
        AMQClient.connectionMade(self)
        self.default_log_level = self.factory.log_level is not None and self.factory.log_level or self.default_log_level

        # Flag that this protocol is not connected yet.
        self.connected = False

        # Authenticate.
        try:
            yield self.start(self.factory.credentials)
        except Exception:
            logger.error("Authentication failed: {}".format(traceback.format_exc()))
            returnValue(None)

        # Authenticated!
        try:
            self.chan = yield self.channel(self.get_channel_number())
        except Exception:
            logger.error("Failed to get channel: {}".format(traceback.format_exc()))
            returnValue(None)

        # You now have a channel!
        try:
            yield self.chan.channel_open()
        except Exception:
            logger.error("Failed to open channel: {}".format(traceback.format_exc()))
            returnValue(None)

        # Mark the connection as open.
        self.connected = True
        logger.info('AMQP connection made.')

        # Now that the channel is open add any readers the user has specified.
        for consumer in self.factory.consumers:
            self.read(consumer)

        # Send any messages waiting to be sent.
        self.send()

        # Fire the factory's 'initial connect' deferred if it hasn't already
        if not self.factory.deferred.called:
            self.factory.deferred.callback(self)
开发者ID:gdoermann,项目名称:classymq,代码行数:45,代码来源:protocol.py

示例10: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
    def connectionMade(self):
        """Called when a connection has been made."""
        self.factory.log.info("Connection made to %s:%s" % (self.factory.config.host, self.factory.config.port))
        AMQClient.connectionMade(self)

        self.factory.connectDeferred.callback(self)
开发者ID:AlternativeValue-ALVA,项目名称:jasmin,代码行数:8,代码来源:protocol.py

示例11: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self, *args, **kwargs):
     AMQClient.connectionMade(self, *args, **kwargs)
     self.factory.onConnectionMade.callback(self)
开发者ID:euan,项目名称:richmond,代码行数:5,代码来源:base.py

示例12: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     AMQClient.connectionMade(self)
     df = self.connect()
     df.addCallback(self.connect_success)
开发者ID:FZambia,项目名称:cyclone-sse,代码行数:6,代码来源:amqp.py

示例13: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     AMQClient.connectionMade(self)
     self.connected_callback(self)
开发者ID:deepakhajare,项目名称:maas,代码行数:5,代码来源:amqpclient.py

示例14: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     AMQClient.connectionMade(self)
     log.listener("New AMQP connection made")
     self.setup()
     wfd = waitForDeferred(self.receive_loop())
     yield wfd
开发者ID:devsfr,项目名称:carbon,代码行数:8,代码来源:amqp_listener.py

示例15: connectionMade

# 需要导入模块: from txamqp.protocol import AMQClient [as 别名]
# 或者: from txamqp.protocol.AMQClient import connectionMade [as 别名]
 def connectionMade(self):
     AMQClient.connectionMade(self)
     self.factory.gotConnection(self)
开发者ID:yunmanger1,项目名称:task-mapreduce,代码行数:5,代码来源:utils.py


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