Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

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

Merged
merged 1 commit into from

2 participants

@jarmo

Instead of printing - NO tuple wait until at least one slave is loaded.

@jarmo jarmo referenced this pull request in guard/guard-spork
Merged

Patch for Rinda::RingFinger.primary #91

@timcharper timcharper merged commit 935bb62 into from
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
This page is out of date. Refresh to see the latest.
Showing with 16 additions and 18 deletions.
  1. +16 −18 lib/spork/run_strategy/magazine.rb
View
34 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)
Something went wrong with that request. Please try again.