<commit_before>module Sidekiq::LimitFetch::Redis
  extend self

  # prevent blocking of fetcher
  # more bullet-proof and faster (O_O)
  # than using Celluloid::IO
  #
  # https://github.com/brainopia/sidekiq-limit_fetch/issues/41
  # explanation of why Future#value is beneficial here
  def nonblocking_redis
    redis do |redis|
      begin
        Celluloid::Future.new { yield redis }.value
      end
    end
  rescue Celluloid::Task::TerminatedError
  end

  def redis
    Sidekiq.redis {|it| yield it }
  end

  def determine_namespace
    redis do |it|
      if it.respond_to?(:namespace) and it.namespace
        it.namespace + ':'
      end
    end
  end
end
<commit_msg>Fix #51, #50 for broken celluloid version<commit_after>module Sidekiq::LimitFetch::Redis
  extend self

  def nonblocking_redis
    redis do |redis|
      # Celluloid 0.16 broke this method
      if Celluloid::VERSION.to_f >= 0.16
        yield redis
      else
      # prevent blocking of fetcher
      # more bullet-proof and faster (O_O)
      # than using Celluloid::IO
      #
      # https://github.com/brainopia/sidekiq-limit_fetch/issues/41
      # explanation of why Future#value is beneficial here
        begin
          Celluloid::Future.new { yield redis }.value
        rescue Celluloid::Task::TerminatedError
        end
      end
    end
  end

  def redis
    Sidekiq.redis {|it| yield it }
  end

  def determine_namespace
    redis do |it|
      if it.respond_to?(:namespace) and it.namespace
        it.namespace + ':'
      end
    end
  end
end

{'fraction_non_alphanumeric': 0.08209437621202327, 'fraction_numerical': 0.00904977375565611, 'mean_word_length': 2.4864864864864864, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 4, 'https://': 2, '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': '4490518', 'n_tokens_mistral': 515, 'n_tokens_neox': 496, 'n_words': 138}