Skip to content

Commit

Permalink
Merge pull request #217 from jarmo/slaves_loaded
Browse files Browse the repository at this point in the history
Wait until magazine slave is loaded when running instead of bailing out.
  • Loading branch information
timcharper committed Oct 28, 2012
2 parents a07c59d + 05ab3c6 commit 935bb62
Showing 1 changed file with 16 additions and 18 deletions.
34 changes: 16 additions & 18 deletions lib/spork/run_strategy/magazine.rb
Original file line number Original file line Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
# to boldly just run test after test # to boldly just run test after test
# as they come in # as they come in
require 'drb' require 'drb'
require 'timeout'
require 'rinda/ring' require 'rinda/ring'
if RUBY_PLATFORM =~ /mswin|mingw/ and RUBY_VERSION < '1.9.1' if RUBY_PLATFORM =~ /mswin|mingw/ and RUBY_VERSION < '1.9.1'
begin begin
Expand Down Expand Up @@ -84,24 +85,21 @@ def self.available?
end end


def run(argv, stderr, stdout) def run(argv, stderr, stdout)
DRb.start_service DRb.start_service
ts = Rinda::RingFinger.primary ts = Rinda::RingFinger.primary
if ts.read_all([:name, :MagazineSlave, nil, nil]).size > 0 Timeout.timeout(60) {sleep 0.1 until ts.read_all([:name, :MagazineSlave, nil, nil]).size > 0}
print ' <-- take tuple'; stdout.flush print ' <-- take tuple'; stdout.flush
tuple = ts.take([:name, :MagazineSlave, nil, nil]) tuple = ts.take([:name, :MagazineSlave, nil, nil])
slave = tuple[2] slave = tuple[2]
id = tuple[3] id = tuple[3]


puts "(#{slave.id_num}); slave.run..."; $stdout.flush puts "(#{slave.id_num}); slave.run..."; $stdout.flush
begin begin
slave.run(argv,stderr,stdout) slave.run(argv,stderr,stdout)
puts " -- (#{slave.id_num});run done"; $stdout.flush puts " -- (#{slave.id_num});run done"; $stdout.flush
ensure ensure
restart_slave(id) restart_slave(id)
end end
else
puts '- NO tuple'; $stdout.flush
end
end end


def restart_slave(id) def restart_slave(id)
Expand Down

0 comments on commit 935bb62

Please sign in to comment.