<commit_before>require 'net/ssh/loggable'
require 'net/ssh/connection/channel'
require 'net/ssh/connection/constants'
require 'net/ssh/service/forward'

module Net; module SSH; module Connection

  class Session
    include Constants, Loggable

    MAP = Constants.constants.inject({}) do |memo, name|
      memo[const_get(name)] = name.downcase.to_sym
      memo
    end

    attr_reader :transport
    attr_reader :channels
    attr_reader :listeners
    attr_reader :pending_requests
    attr_reader :readers
    attr_reader :writers
    attr_reader :channel_open_handler

    def initialize(transport, options={})
      self.logger = transport.logger

      @transport = transport

      @channel_id_counter = -1
      @channels = {}
      @listeners = {}
      @pending_requests = []
      @readers = [transport.socket]
      @writers = [transport.socket]
      @channel_open_handler = {}
    end

    def close
      channels.each { |id, channel| channel.close }
      loop(0) { channels.any? }
      transport.close
    end

    # preserve a reference to Kernel#loop
    alias :loop_forever :loop

    def loop(wait=nil, &block)
      running = block || Proc.new { channels.any? { |id,ch| !ch[:invisible] } }
      process(wait) while running.call
    end

    def process(wait=nil)
      dispatch_incoming_packets
      channels.each { |id, channel| channel.process unless channel.closing? }
<commit_msg>add some logging<commit_after>require 'net/ssh/loggable'
require 'net/ssh/connection/channel'
require 'net/ssh/connection/constants'
require 'net/ssh/service/forward'

module Net; module SSH; module Connection

  class Session
    include Constants, Loggable

    MAP = Constants.constants.inject({}) do |memo, name|
      memo[const_get(name)] = name.downcase.to_sym
      memo
    end

    attr_reader :transport
    attr_reader :channels
    attr_reader :listeners
    attr_reader :pending_requests
    attr_reader :readers
    attr_reader :writers
    attr_reader :channel_open_handler

    def initialize(transport, options={})
      self.logger = transport.logger

      @transport = transport

      @channel_id_counter = -1
      @channels = {}
      @listeners = {}
      @pending_requests = []
      @readers = [transport.socket]
      @writers = [transport.socket]
      @channel_open_handler = {}
    end

    def close
      debug { "closing remaining channels (#{channels.length} open)" }
      channels.each { |id, channel| channel.close }
      loop(0) { channels.any? }
      transport.close
    end

    # preserve a reference to Kernel#loop
    alias :loop_forever :loop

    def loop(wait=nil, &block)
      running = block || Proc.new { channels.any? { |id,ch| !ch[:invisible] } }
      process(wait) while running.call
    end

    def process(wait=nil)
      dispatch_incoming_packets
      channels.each { |id, channel| channel.process unless channel.closing? }

{'fraction_non_alphanumeric': 0.1028295376121463, 'fraction_numerical': 0.0013802622498274672, 'mean_word_length': 2.982142857142857, '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': '7466066', 'n_tokens_mistral': 897, 'n_tokens_neox': 863, 'n_words': 208}