<commit_before>
require 'rainbows/event_machine_thread_pool'

class Rainbows::EventMachineThreadPool::Client <
      Rainbows::EventMachine::Client

  def app_call input
    # begin Copied from Rainbows::EventMachine::Client#app_call
    set_comm_inactivity_timeout 0
    @env[RACK_INPUT] = input
    @env[REMOTE_ADDR] = @_io.kgio_addr
    @env[ASYNC_CALLBACK] = method(:write_async_response)
    @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new
    @hp.hijack_setup(@env, @_io)
    # end Copied from Rainbows::EventMachine::Client#app_call

    @deferred = true # We defer immediately
    EM.defer do      # Queue the application call to EM's job queue
      begin
        status, headers, body = catch(:async) {
          APP.call(@env.merge!(RACK_DEFAULTS))
        }
        if @hp.hijacked?
          ; # do nothing
        elsif nil == status || -1 == status
          @deferred = true
        else
          @deferred = nil
          ev_write_response(status, headers, body, @hp.next?)
        end
      # Never ever crash any thread
      rescue Exception => e
        if handler = EM.instance_variable_get(:@error_handler)
          handler.call(e)
        end
        handle_error(e)
      end<commit_msg>i think in the case of hijacking, the user should take responsibility<commit_after>
require 'rainbows/event_machine_thread_pool'

class Rainbows::EventMachineThreadPool::Client <
      Rainbows::EventMachine::Client

  def app_call input
    # begin Copied from Rainbows::EventMachine::Client#app_call
    set_comm_inactivity_timeout 0
    @env[RACK_INPUT] = input
    @env[REMOTE_ADDR] = @_io.kgio_addr
    @env[ASYNC_CALLBACK] = method(:write_async_response)
    @env[ASYNC_CLOSE] = EM::DefaultDeferrable.new
    @hp.hijack_setup(@env, @_io)
    # end Copied from Rainbows::EventMachine::Client#app_call

    @deferred = true # We defer immediately
    EM.defer do      # Queue the application call to EM's job queue
      begin
        status, headers, body = catch(:async) {
          APP.call(@env.merge!(RACK_DEFAULTS))
        }
        if @hp.hijacked?
          @deferred = nil
        elsif nil == status || -1 == status
          @deferred = true
        else
          @deferred = nil
          ev_write_response(status, headers, body, @hp.next?)
        end
      # Never ever crash any thread
      rescue Exception => e
        if handler = EM.instance_variable_get(:@error_handler)
          handler.call(e)
        end
        handle_error(e)
      end
{'fraction_non_alphanumeric': 0.09552599758162031, 'fraction_numerical': 0.0016122531237404273, 'mean_word_length': 2.698956780923994, 'pattern_counts': {'":': 0, '<': 5, '<?xml version=': 0, '>': 5, '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': '1880968', 'n_tokens_mistral': 791, 'n_tokens_neox': 764, 'n_words': 178}