<commit_before># encoding: utf-8

class RecoverTaskWorker
  include Sidekiq::Worker

  # only try 2x to recover, which should be enough.
  sidekiq_options :retry => 2

  def perform(task_id)
    ActiveRecord::Base.connection_pool.with_connection do
      task = Task.find_by_id(task_id)
      begin
        task.recover! if task
      rescue StateMachine::InvalidTransition => err
        logger.warn "RecoverTaskWorker: StateMachine::InvalidTransition: task: #{task_id}, err: #{err.message}"
      end
      true
    end
  end

end<commit_msg>call task.owner.check_tasks so that recovery followed by new task(s) if necessary<commit_after># encoding: utf-8

class RecoverTaskWorker
  include Sidekiq::Worker

  # only try 2x to recover, which should be enough.
  sidekiq_options :retry => 2

  def perform(task_id)
    ActiveRecord::Base.connection_pool.with_connection do
      task = Task.find_by_id(task_id)
      begin
        if task
          task.recover!
          task.owner.check_tasks
        end
      rescue StateMachine::InvalidTransition => err
        logger.warn "RecoverTaskWorker: StateMachine::InvalidTransition: task: #{task_id}, err: #{err.message}"
      end
      true
    end
  end

end
{'fraction_non_alphanumeric': 0.08257638315441784, 'fraction_numerical': 0.00495458298926507, 'mean_word_length': 3.1649484536082473, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 7, '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': '2471570', 'n_tokens_mistral': 368, 'n_tokens_neox': 363, 'n_words': 99}