summaryrefslogtreecommitdiffstats
path: root/nova
diff options
context:
space:
mode:
authorJosh Kearney <josh.kearney@rackspace.com>2010-11-20 21:04:35 +0000
committerTarmac <>2010-11-20 21:04:35 +0000
commit4730b2037d4b53cd79c7d46965c5cafa1912c812 (patch)
tree9b6b167e5f314e61c7f1871c2aa5eb7b0ee99607 /nova
parentacf8800d73215b5b0974dd64f0047a9fc6c0a4c7 (diff)
parent874edc5103e1ebbe1def1639ef056574dcd406e9 (diff)
Check for running AMQP instances.
Diffstat (limited to 'nova')
-rw-r--r--nova/rpc.py19
1 files changed, 16 insertions, 3 deletions
diff --git a/nova/rpc.py b/nova/rpc.py
index ea36d69f4..9938b0838 100644
--- a/nova/rpc.py
+++ b/nova/rpc.py
@@ -24,6 +24,7 @@ No fan-out support yet.
import json
import logging
import sys
+import time
import uuid
from carrot import connection as carrot_connection
@@ -83,7 +84,18 @@ class Consumer(messaging.Consumer):
"""
def __init__(self, *args, **kwargs):
self.failed_connection = False
- super(Consumer, self).__init__(*args, **kwargs)
+
+ while True:
+ try:
+ super(Consumer, self).__init__(*args, **kwargs)
+ break
+ except: # Catching all because carrot sucks
+ logging.exception("AMQP server on %s:%d is unreachable. " \
+ "Trying again in 30 seconds." % (
+ FLAGS.rabbit_host,
+ FLAGS.rabbit_port))
+ time.sleep(30)
+ continue
def fetch(self, no_ack=None, auto_ack=None, enable_callbacks=False):
"""Wraps the parent fetch with some logic for failed connections"""
@@ -94,8 +106,9 @@ class Consumer(messaging.Consumer):
# NOTE(vish): conn is defined in the parent class, we can
# recreate it as long as we create the backend too
# pylint: disable-msg=W0201
- self.conn = Connection.recreate()
- self.backend = self.conn.create_backend()
+ self.connection = Connection.recreate()
+ self.backend = self.connection.create_backend()
+ self.declare()
super(Consumer, self).fetch(no_ack, auto_ack, enable_callbacks)
if self.failed_connection:
logging.error("Reconnected to queue")