<commit_before>module Wukong
  module Load
    class SourceDriver < Wukong::Local::StdioDriver
      include Logging

      attr_accessor :index

      def post_init
        super()
        self.index = 1
      end

      def self.start(label, settings={})
        driver = new(:foobar, label, settings)
        driver.post_init
        period = (1.0 / (settings[:per_sec] || 1.0))
        EventMachine::PeriodicTimer.new(period) { driver.create_event }
      end

      def create_event
        receive_line(index.to_s)
        self.index += 1
      end
      
    end
  end
end
<commit_msg>override process method of StdioDriver to flush on each write<commit_after>module Wukong
  module Load
    class SourceDriver < Wukong::Local::StdioDriver
      include Logging

      attr_accessor :index

      def post_init
        super()
        self.index = 1
      end

      def self.start(label, settings={})
        driver = new(:foobar, label, settings)
        driver.post_init
        period = (1.0 / (settings[:per_sec] || 1.0))
        EventMachine::PeriodicTimer.new(period) { driver.create_event }
      end

      def create_event
        receive_line(index.to_s)
        self.index += 1
      end

      # :nodoc:
      #
      # Not sure why I have to add the call to $stdout.flush at the
      # end of this method.  Supposedly $stdout.sync is called during
      # the #setup method in StdoutProcessor in
      # wukong/widget/processors.  Doesn't that do this?
      def process record
        $stdout.puts record
        $stdout.flush
      end
      
    end
  end
end

{'fraction_non_alphanumeric': 0.08264984227129338, 'fraction_numerical': 0.007570977917981073, 'mean_word_length': 2.0383141762452106, 'pattern_counts': {'":': 0, '<': 5, '<?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': '2864795', 'n_tokens_mistral': 492, 'n_tokens_neox': 473, 'n_words': 132}