Mercurial > srxproxy
changeset 35:2bbc58bc81e7
Add retries for connecting to queue
| author | Radomir Dopieralski <sheep-devel@sheep.art.pl> |
|---|---|
| date | Wed, 13 Feb 2013 16:23:33 +0100 |
| parents | 29b0aa997665 |
| children | 727fd98b7b78 |
| files | srxproxy.py |
| diffstat | 1 files changed, 11 insertions(+), 1 deletions(-) [+] |
line wrap: on
line diff
--- a/srxproxy.py Wed Feb 13 14:59:15 2013 +0100 +++ b/srxproxy.py Wed Feb 13 16:23:33 2013 +0100 @@ -284,7 +284,17 @@ log.setup() assoc_acc = Accumulator(DELAY) dis_acc = Accumulator(DELAY) - connection = rpc.create_connection() + for retry in xrange(FLAGS.netconf_retries): + try: + connection = rpc.create_connection() + except Exception as error: + log.warning("Can't connect, retry %d", retry + 1) + eventlet.sleep(2**retry + 1) + else: + break + else: + log.error("Failed to connect.") + log.exception(error) connection.declare_topic_consumer('srxproxy', on_message) connection.declare_topic_consumer('srxproxy.%s' % flags.FLAGS.host, on_message) connection.consume_in_thread()
