Permalink
Browse files

Merge pull request #217 from jarmo/slaves_loaded

Wait until magazine slave is loaded when running instead of bailing out.
  • Loading branch information...
2 parents a07c59d + 05ab3c6 commit 935bb621b2ba0e3530c26ab4312b7b015dcd8b95 @timcharper timcharper committed Oct 28, 2012
Showing with 16 additions and 18 deletions.
  1. +16 −18 lib/spork/run_strategy/magazine.rb
@@ -2,6 +2,7 @@
# to boldly just run test after test
# as they come in
require 'drb'
+require 'timeout'
require 'rinda/ring'
if RUBY_PLATFORM =~ /mswin|mingw/ and RUBY_VERSION < '1.9.1'
begin
@@ -84,24 +85,21 @@ def self.available?
end
def run(argv, stderr, stdout)
- DRb.start_service
- ts = Rinda::RingFinger.primary
- if ts.read_all([:name, :MagazineSlave, nil, nil]).size > 0
- print ' <-- take tuple'; stdout.flush
- tuple = ts.take([:name, :MagazineSlave, nil, nil])
- slave = tuple[2]
- id = tuple[3]
-
- puts "(#{slave.id_num}); slave.run..."; $stdout.flush
- begin
- slave.run(argv,stderr,stdout)
- puts " -- (#{slave.id_num});run done"; $stdout.flush
- ensure
- restart_slave(id)
- end
- else
- puts '- NO tuple'; $stdout.flush
- end
+ DRb.start_service
+ ts = Rinda::RingFinger.primary
+ Timeout.timeout(60) {sleep 0.1 until ts.read_all([:name, :MagazineSlave, nil, nil]).size > 0}
+ print ' <-- take tuple'; stdout.flush
+ tuple = ts.take([:name, :MagazineSlave, nil, nil])
+ slave = tuple[2]
+ id = tuple[3]
+
+ puts "(#{slave.id_num}); slave.run..."; $stdout.flush
+ begin
+ slave.run(argv,stderr,stdout)
+ puts " -- (#{slave.id_num});run done"; $stdout.flush
+ ensure
+ restart_slave(id)
+ end
end
def restart_slave(id)

0 comments on commit 935bb62

Please sign in to comment.