def insured(pool, fun, args, kwargs, errback=None, on_revive=None, **opts):
 errback = (errback or _ensure_errback)
 with pool.acquire(block=True) as conn:
  conn.ensure_connection(errback=errback)
  channel = conn.default_channel
  revive = partial(revive_connection, conn, on_revive=on_revive)
  insured = conn.autoretry(fun, channel, errback=errback, on_revive=revive, **opts)
  (retval, _) = insured(*args, **dict(kwargs, connection=conn))
  return retval

def insured ( pool , fun , args , kwargs , errback = None , on_revive = None , ** opts ) : errback = ( errback or _ensure_errback ) with pool . acquire ( block = True ) as conn : conn . ensure_connection ( errback = errback ) channel = conn . default_channel revive = partial ( revive_connection , conn , on_revive = on_revive ) insured = conn . autoretry ( fun , channel , errback = errback , on_revive = revive , ** opts ) ( retval , _ ) = insured ( * args , ** dict ( kwargs , connection = conn ) ) return retval
function wrapper to handle connection errors .