From 985a1f025f62135320916ed0c03e156617db8d9f Mon Sep 17 00:00:00 2001 From: Ask Solem Date: Wed, 4 Aug 2010 08:33:48 +0200 Subject: [PATCH] Some typos in Connection.ensure --- kombu/backends/pyamqplib.py | 5 ++++- kombu/connection.py | 9 +++++++-- 2 files changed, 11 insertions(+), 3 deletions(-) diff --git a/kombu/backends/pyamqplib.py b/kombu/backends/pyamqplib.py index 446b692c..c8fefe9a 100644 --- a/kombu/backends/pyamqplib.py +++ b/kombu/backends/pyamqplib.py @@ -169,7 +169,10 @@ class Channel(Channel): class Backend(BaseBackend): default_port = DEFAULT_PORT - connection_errors = (AMQPConnectionException, socket.error, IOError) + connection_errors = (AMQPConnectionException, + socket.error, + IOError, + OSError) channel_errors = (AMQPChannelException, ) def __init__(self, client, **kwargs): diff --git a/kombu/connection.py b/kombu/connection.py index d4e511d1..39c0c24e 100644 --- a/kombu/connection.py +++ b/kombu/connection.py @@ -4,6 +4,7 @@ import threading from collections import deque from copy import copy from functools import wraps +from itertools import count from time import time from kombu import exceptions @@ -172,21 +173,25 @@ class BrokerConnection(object): """ + max_retries = max_retries or 0 + @wraps(fun) def _insured(*args, **kwargs): - for retries in count(0): + for ret in count(0): if max_retries and retries >= max_retries: raise exceptions.EnsureExhausted() try: return fun(*args, **kwargs) except self.connection_errors + self.channel_errors, exc: errback and errback(exc, 0) + self.connection.connection = None self.close() self.ensure_connection(errback, - max_retries - retries, + max(max_retries - retries, 1), interval_start, interval_step, interval_max) + _insured.func_name = _insured.__name__ = "%s(insured)" % fun.__name__ return _insured