Some typos in Connection.ensure

This commit is contained in:
Ask Solem 2010-08-04 08:33:48 +02:00
parent 4b2f4d47e4
commit 985a1f025f
2 changed files with 11 additions and 3 deletions

View File

@ -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):

View File

@ -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