public
Rubygem
Description: Don't mind this, go to http://github.com/integrity/integrity
Homepage: http://integrityapp.com
Clone URL: git://github.com/foca/integrity.git
protection against timeout of notifiers
sr (author)
Thu Nov 20 12:02:01 -0800 2008
commit  26663031d7513ccf10bff921ef377509d713dd85
tree    c08de6bc2dd6f1b3372d293c3f71bcbd806c527b
parent  f14f9b360d9d68cf987994ed3617fbce25e5cd1d
...
2
3
4
5
 
6
7
8
...
2
3
4
 
5
6
7
8
0
@@ -2,7 +2,7 @@ module Integrity
0
   class Notifier
0
     class Base
0
       def self.notify_of_build(build, config)
0
-        new(build, config).deliver!
0
+        Timeout.timeout(8) { new(build, config).deliver! }
0
       end
0
 
0
       def self.to_haml
...
76
77
78
79
 
 
 
 
 
80
81
82
...
76
77
78
 
79
80
81
82
83
84
85
86
0
@@ -76,7 +76,11 @@ module Integrity
0
       
0
       def send_notifications
0
         notifiers.each do |notifier|
0
-          notifier.notify_of_build last_build
0
+          begin
0
+            notifier.notify_of_build last_build
0
+          rescue Timeout::Error
0
+            next
0
+          end
0
         end
0
       end
0
   end
...
271
272
273
 
 
 
 
 
 
 
274
275
...
271
272
273
274
275
276
277
278
279
280
281
282
0
@@ -271,5 +271,12 @@ describe Integrity::Project do
0
       @email_notifier.should_receive(:notify_of_build).with(mock_build)
0
       @project.send(:send_notifications)
0
     end
0
+
0
+    it "should protect itself from eventual timeout error" do
0
+      @email_notifier.stub!(:notify_of_build).and_raise(Timeout::Error)
0
+      lambda do
0
+        @project.send(:send_notifications)
0
+      end.should_not raise_error
0
+    end
0
   end
0
 end

Comments