def locked_action(lock_name, raise_on_locked = false)
      begin
        self[lock_name].lock do
          yield
        end
      rescue => e
        if e.class.to_s.end_with?("Timeout")
          raise if raise_on_locked
        else
          raise
        end
      end
    end
def locked_action(lock_name, raise_on_locked = false)
      begin
        self[lock_name].lock do
          yield
        end
      rescue => e
        if e.class.to_s.end_with?("Timeout")
          raise if raise_on_locked
        else
          raise
        end
      end
    end
Perform action within lock

 @param lock_name [String, Symbol] name of lock
 @param raise_on_locked [TrueClass, FalseClass] raise execption if lock wait times out
 @return [Object] result of yield