本文整理汇总了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)
示例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")
示例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)
示例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)
示例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
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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)
示例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
示例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)