arya-pandemic 0.3.8 → 0.3.9

Sign up to get free protection for your applications and to get access to all the features.
data/Rakefile CHANGED
@@ -2,7 +2,7 @@ require 'rubygems'
2
2
  require 'rake'
3
3
  require 'echoe'
4
4
 
5
- Echoe.new('pandemic', '0.3.8') do |p|
5
+ Echoe.new('pandemic', '0.3.9') do |p|
6
6
  p.description = "Distribute MapReduce to any of the workers and it will spread, like a pandemic."
7
7
  p.url = "https://github.com/arya/pandemic/"
8
8
  p.author = "Arya Asemanfar"
@@ -44,6 +44,7 @@ module Pandemic
44
44
  key, options = nil, key if key.is_a?(Hash)
45
45
  with_connection(key) do |socket|
46
46
  begin
47
+ raise LostConnectionToNode if socket.nil?
47
48
  flags = []
48
49
  if options[:async]
49
50
  flags << "a"
@@ -64,7 +65,7 @@ module Pandemic
64
65
  raise LostConnectionToNode
65
66
  end
66
67
  end
67
- rescue Errno::ECONNRESET
68
+ rescue Errno::ECONNRESET, Errno::EPIPE
68
69
  raise LostConnectionToNode
69
70
  end
70
71
  end
@@ -76,6 +77,9 @@ module Pandemic
76
77
  begin
77
78
  connection = checkout_connection(key)
78
79
  block.call(connection.socket)
80
+ rescue LostConnectionToNode
81
+ connection.died!
82
+ raise
79
83
  ensure
80
84
  checkin_connection(connection) if connection
81
85
  end
@@ -90,6 +94,8 @@ module Pandemic
90
94
  if select_from.size > 0
91
95
  connection = select_from.pop
92
96
  connection.ensure_alive!
97
+ break unless connection.alive?
98
+
93
99
  if key.nil?
94
100
  @grouped_available[key].delete(connection)
95
101
  else
@@ -12,7 +12,12 @@ module Pandemic
12
12
  end
13
13
 
14
14
  def ensure_alive!
15
- connect unless alive?
15
+ connect unless self.alive?
16
+ end
17
+
18
+ def died!
19
+ @socket.close if self.alive?
20
+ @socket = nil
16
21
  end
17
22
 
18
23
  private
@@ -2,7 +2,7 @@
2
2
 
3
3
  Gem::Specification.new do |s|
4
4
  s.name = %q{pandemic}
5
- s.version = "0.3.8"
5
+ s.version = "0.3.9"
6
6
 
7
7
  s.required_rubygems_version = Gem::Requirement.new(">= 1.2") if s.respond_to? :required_rubygems_version=
8
8
  s.authors = ["Arya Asemanfar"]
metadata CHANGED
@@ -1,7 +1,7 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: arya-pandemic
3
3
  version: !ruby/object:Gem::Version
4
- version: 0.3.8
4
+ version: 0.3.9
5
5
  platform: ruby
6
6
  authors:
7
7
  - Arya Asemanfar