Skip to content

Commit

Permalink
protection against timeout of notifiers
Browse files Browse the repository at this point in the history
  • Loading branch information
sr committed Nov 20, 2008
1 parent f14f9b3 commit 2666303
Show file tree
Hide file tree
Showing 3 changed files with 13 additions and 2 deletions.
2 changes: 1 addition & 1 deletion lib/integrity/notifier/base.rb
Expand Up @@ -2,7 +2,7 @@ module Integrity
class Notifier
class Base
def self.notify_of_build(build, config)
new(build, config).deliver!
Timeout.timeout(8) { new(build, config).deliver! }
end

def self.to_haml
Expand Down
6 changes: 5 additions & 1 deletion lib/integrity/project.rb
Expand Up @@ -76,7 +76,11 @@ def delete_code

def send_notifications
notifiers.each do |notifier|
notifier.notify_of_build last_build
begin
notifier.notify_of_build last_build
rescue Timeout::Error
next
end
end
end
end
Expand Down
7 changes: 7 additions & 0 deletions spec/project_spec.rb
Expand Up @@ -271,5 +271,12 @@ def mock_build
@email_notifier.should_receive(:notify_of_build).with(mock_build)
@project.send(:send_notifications)
end

it "should protect itself from eventual timeout error" do
@email_notifier.stub!(:notify_of_build).and_raise(Timeout::Error)
lambda do
@project.send(:send_notifications)
end.should_not raise_error
end
end
end

0 comments on commit 2666303

Please sign in to comment.