Sha256: 902079f63ab87258638f9b01cd1e8204dbbccf8718562fa7cc871518305a2426

Contents?: true

Size: 891 Bytes

Versions: 24

Compression:

Stored size: 891 Bytes

Contents

module DeepTest
  class ResultReader
    def initialize(blackboard)
      @blackboard = blackboard
    end

    def read(original_work_units_by_id)
      work_units_by_id = original_work_units_by_id.dup
      errors = 0

      begin
        until errors == work_units_by_id.size
          Thread.pass
          result = @blackboard.take_result
          next if result.nil?

          if Worker::Error === result
            puts result
            errors += 1
          else
            if result.respond_to?(:output) && (output = result.output)
              print output
            end

            work_unit = work_units_by_id.delete(result.identifier)
            yield [work_unit, result]
          end
        end
      rescue Server::ResultOverdueError
        DeepTest.logger.error("Results are overdue from server, ending run")
      end

      work_units_by_id
    end
  end
end

Version data entries

24 entries across 24 versions & 4 rubygems

Version Path
jstorimer-deep-test-1.0.0 lib/deep_test/result_reader.rb
deep_test-1.2.0 lib/deep_test/result_reader.rb
deep_test-1.2.2 lib/deep_test/result_reader.rb
deep_test-1.2.1 lib/deep_test/result_reader.rb