class Redis::Client
def ensure_connected
def ensure_connected tries = 0 begin if connected? if Process.pid != @pid raise InheritedError, "Tried to use a connection from a child process without reconnecting. " + "You need to reconnect to Redis after forking." end else connect end tries += 1 yield rescue ConnectionError disconnect if tries < 2 && @reconnect retry else raise end rescue Exception disconnect raise end end