<commit_before>require 'capybara/dsl'
require 'sidekiq'
require 'statsd'
require 'rspec'
require 'poltergrind/capybara'

module Poltergrind
  module Worker
    def self.included(base)
      base.include Capybara::DSL
      base.include Sidekiq::Worker
      base.include RSpec::Matchers

      base.instance_eval do
        sidekiq_options retry: false, dead: false
      end
    end

    def self.statsd
      @statsd ||= Statsd.new('localhost').tap { |sd| sd.namespace = 'poltergrind' }
    end

    def time(key)
      statsd.time(key) do
        yield
      end
    end

    def statsd
      Poltergrind::Worker.statsd
    end

    def perform
      Capybara.using_session 'poltergrind' do
        yield
      end
    end
  end
end<commit_msg>Sorry Sidekiq! Fork within the worker.<commit_after>require 'capybara/dsl'
require 'sidekiq'
require 'statsd'
require 'rspec'
require 'poltergrind/capybara'

module Poltergrind
  module Worker
    def self.included(base)
      base.include Capybara::DSL
      base.include Sidekiq::Worker
      base.include RSpec::Matchers

      base.instance_eval do
        sidekiq_options retry: false, dead: false
      end
    end

    def self.statsd
      @statsd ||= Statsd.new('localhost').tap { |sd| sd.namespace = 'poltergrind' }
    end

    def time(key)
      statsd.time(key) do
        yield
      end
    end

    def statsd
      Poltergrind::Worker.statsd
    end

    def perform
      @fork_pid = fork do
        Capybara.using_session 'poltergrind' do
          yield
        end
      end

      Process.waitpid(@fork_pid)
    end
  end
end
{'fraction_non_alphanumeric': 0.08150470219435736, 'fraction_numerical': 0.0, 'mean_word_length': 2.3742071881606766, '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': '3796283', 'n_tokens_mistral': 546, 'n_tokens_neox': 526, 'n_words': 129}