Permalink
Browse files

Wait until magazine slave is loaded when running instead of bailing out.

  • Loading branch information...
1 parent a07c59d commit 05ab3c69a4732a4babc2cb5a501a67a68e629173 @jarmo jarmo committed Oct 27, 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 05ab3c6

Please sign in to comment.