Sha256: f5a34916a348fd521b3fd5b39736db9db11122c31dd568d1584242e73627bc39
Contents?: true
Size: 1.9 KB
Versions: 1
Compression:
Stored size: 1.9 KB
Contents
module Paraduct require "thread/pool" class ParallelRunner # run script with arguments # @param script [String, Array<String>] script file, script(s) # @param product_variables [Array<Hash{String => String}>] # @return [Paraduct::TestResponse] def self.perform_all(script, product_variables) test_response = Paraduct::TestResponse.new base_job_dir = Paraduct.config.work_dir FileUtils.mkdir_p(base_job_dir) unless base_job_dir.exist? Paraduct.logger.info <<-EOS ====================================================== START matrix test EOS pool = Thread.pool(Paraduct.config.max_threads) begin product_variables.each_with_index do |params, index| runner = Paraduct::Runner.new( script: script, params: params, base_job_dir: base_job_dir, job_id: index + 1, ) pool.process do runner.logger.info "[START] params: #{runner.formatted_params}" runner.setup_dir begin stdout = runner.perform successful = true rescue Paraduct::Errors::ProcessError => e runner.logger.error "exitstatus=#{e.status}, #{e.inspect}" stdout = e.message successful = false end runner.logger.info "[END] params: #{runner.formatted_params}" test_response.jobs_push( job_name: runner.job_name, params: runner.params, formatted_params: runner.formatted_params, successful: successful, stdout: stdout, ) end end ensure pool.shutdown end raise Paraduct::Errors::DirtyExitError unless test_response.jobs_count == product_variables.count test_response end end end
Version data entries
1 entries across 1 versions & 1 rubygems
Version | Path |
---|---|
paraduct-0.0.1.beta14 | lib/paraduct/parallel_runner.rb |