<commit_before>require 'active_job/retriable/version'

module ActiveJob
  module Retriable
    extend ActiveSupport::Concern

    DEFAULT_MAX    = 25
    DEFAULT_FACTOR = 4

    included do
      # TODO think about how to handle ActiveJob::DeserializationError
      rescue_from Exception do |ex|
        tag_logger self.class.name, job_id do
          if retries_exhausted?
            logger.info "Retries exhauseted at #{retry_attempt}"

          else
            logger.warn "Retrying due to #{ex.message} on #{ex.backtrace.try(:first)}"

            retry_job wait: retry_delay unless retries_exhausted?
          end
        end
      end

      before_perform do
        @retry_attempt += 1
      end
    end

    module ClassMethods
      attr_accessor :retry_max<commit_msg>Make sure @retry_attempt is initialized in the before_perform block<commit_after>require 'active_job/retriable/version'

module ActiveJob
  module Retriable
    extend ActiveSupport::Concern

    DEFAULT_MAX    = 25
    DEFAULT_FACTOR = 4

    included do
      # TODO think about how to handle ActiveJob::DeserializationError
      rescue_from Exception do |ex|
        tag_logger self.class.name, job_id do
          if retries_exhausted?
            logger.info "Retries exhauseted at #{retry_attempt}"

          else
            logger.warn "Retrying due to #{ex.message} on #{ex.backtrace.try(:first)}"

            retry_job wait: retry_delay unless retries_exhausted?
          end
        end
      end

      before_perform do
        @retry_attempt ||= 0
        @retry_attempt += 1
      end
    end

    module ClassMethods
      attr_accessor :retry_max
{'fraction_non_alphanumeric': 0.05996365838885524, 'fraction_numerical': 0.005451241671714113, 'mean_word_length': 2.3577235772357725, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '1047150', 'n_tokens_mistral': 490, 'n_tokens_neox': 474, 'n_words': 133}