diff --git a/lib/hydra/master.rb b/lib/hydra/master.rb index c186208..09c5550 100644 --- a/lib/hydra/master.rb +++ b/lib/hydra/master.rb @@ -72,6 +72,18 @@ module Hydra #:nodoc: # default is one worker that is configured to use a pipe with one runner worker_cfg = opts.fetch('workers') { [ { 'type' => 'local', 'runners' => 1} ] } + # if the number of files to run is equal to or less than the count of local + # runners, don't even bother with retmote workers. + locals, sshes = worker_cfg.partition { |l| l['type'] == 'local' } + + if !locals.empty? + if @files.length <= locals.first['runners'] + sshes = [] + end + end + + worker_cfg = locals + sshes + trace "Initialized" trace " Files: (#{@files.inspect})" trace " Workers: (#{worker_cfg.inspect})" diff --git a/lib/hydra/messaging_io.rb b/lib/hydra/messaging_io.rb index 1cab329..10760f3 100644 --- a/lib/hydra/messaging_io.rb +++ b/lib/hydra/messaging_io.rb @@ -11,13 +11,14 @@ module Hydra #:nodoc: while true begin raise IOError unless @reader - if !@timeout || (result = Kernel.select([@reader], [], [], @timeout)) + message = nil + if result = Kernel.select([@reader], [], [], @timeout) message = @reader.gets end return Message.build(:class => Hydra::Messages::Master::Shutdown) if result == nil return nil unless message return Message.build(eval(message.chomp)) - rescue SyntaxError, NameError + rescue SyntaxError, NameError, Errno::EBADF # uncomment to help catch remote errors by seeing all traffic #$stderr.write "Not a message: [#{message.inspect}]\n" end