stapfen 1.4.0 → 1.4.1
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- data/lib/stapfen/version.rb +1 -1
- data/lib/stapfen/worker.rb +8 -3
- data/spec/worker_spec.rb +13 -1
- metadata +3 -3
data/lib/stapfen/version.rb
CHANGED
data/lib/stapfen/worker.rb
CHANGED
@@ -106,12 +106,16 @@ module Stapfen
|
|
106
106
|
end
|
107
107
|
|
108
108
|
begin
|
109
|
-
# Performing this join/
|
109
|
+
# Performing this join/runningloop to make sure that we don't
|
110
110
|
# experience potential deadlocks between signal handlers who might
|
111
111
|
# close the connection, and an infinite Client#join call
|
112
|
-
|
112
|
+
#
|
113
|
+
# Instead of using client#open? we use #running which will still be
|
114
|
+
# true even if the client is currently in an exponential reconnect loop
|
115
|
+
while client.running do
|
113
116
|
client.join(1)
|
114
117
|
end
|
118
|
+
warn("Exiting the runloop for #{self}")
|
115
119
|
rescue Interrupt
|
116
120
|
exit_cleanly
|
117
121
|
end
|
@@ -122,7 +126,8 @@ module Stapfen
|
|
122
126
|
def exit_cleanly
|
123
127
|
self.class.destructor.call if self.class.destructor
|
124
128
|
|
125
|
-
|
129
|
+
# Only close the client if we have one sitting around
|
130
|
+
if client && !client.closed?
|
126
131
|
client.close
|
127
132
|
end
|
128
133
|
end
|
data/spec/worker_spec.rb
CHANGED
@@ -54,7 +54,7 @@ describe Stapfen::Worker do
|
|
54
54
|
end
|
55
55
|
|
56
56
|
context 'unreceive behavior' do
|
57
|
-
let(:client) {
|
57
|
+
let(:client) { double('Stomp::Client', :running => false) }
|
58
58
|
let(:name) { '/queue/some_queue' }
|
59
59
|
before :each do
|
60
60
|
Stomp::Client.stub(:new).and_return(client)
|
@@ -130,6 +130,18 @@ describe Stapfen::Worker do
|
|
130
130
|
client.should_receive(:close)
|
131
131
|
worker.exit_cleanly
|
132
132
|
end
|
133
|
+
|
134
|
+
context 'with out having connected a client yet' do
|
135
|
+
before :each do
|
136
|
+
worker.stub(:client).and_return(nil)
|
137
|
+
end
|
138
|
+
|
139
|
+
it 'should not raise any errors' do
|
140
|
+
expect {
|
141
|
+
worker.exit_cleanly
|
142
|
+
}.not_to raise_error
|
143
|
+
end
|
144
|
+
end
|
133
145
|
end
|
134
146
|
end
|
135
147
|
end
|
metadata
CHANGED
@@ -1,7 +1,7 @@
|
|
1
1
|
--- !ruby/object:Gem::Specification
|
2
2
|
name: stapfen
|
3
3
|
version: !ruby/object:Gem::Version
|
4
|
-
version: 1.4.
|
4
|
+
version: 1.4.1
|
5
5
|
prerelease:
|
6
6
|
platform: ruby
|
7
7
|
authors:
|
@@ -63,7 +63,7 @@ required_ruby_version: !ruby/object:Gem::Requirement
|
|
63
63
|
version: '0'
|
64
64
|
segments:
|
65
65
|
- 0
|
66
|
-
hash: -
|
66
|
+
hash: -1743593967546898414
|
67
67
|
required_rubygems_version: !ruby/object:Gem::Requirement
|
68
68
|
none: false
|
69
69
|
requirements:
|
@@ -72,7 +72,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
|
|
72
72
|
version: '0'
|
73
73
|
segments:
|
74
74
|
- 0
|
75
|
-
hash: -
|
75
|
+
hash: -1743593967546898414
|
76
76
|
requirements: []
|
77
77
|
rubyforge_project:
|
78
78
|
rubygems_version: 1.8.25
|