Skip to content

Commit

Permalink
Use thread for PubsubhubbubNotifier#notify
Browse files Browse the repository at this point in the history
If the method blocks, it keep user waiting until post is over.
It slows response time especially when posting to many hubs.
Joining to main thread is not needed because user and application
need not know whether posting is succeeded or not. We can see it by log.
  • Loading branch information
KitaitiMakoto committed May 25, 2013
1 parent 024e907 commit 8fd2956
Showing 1 changed file with 9 additions and 7 deletions.
16 changes: 9 additions & 7 deletions app/models/pubsubhubbub_notifier.rb
Original file line number Diff line number Diff line change
Expand Up @@ -5,13 +5,15 @@ class << self
attr_accessor :instances

def notify
instances.each do |instance|
begin
instance.notify
rescue => e
Rails.logger.warn "[#{self}.#{__method__}]ERROR: #{e}"
end
end
instances.map {|instance|
Thread.new(instance) {
begin
instance.notify
rescue => e
Rails.logger.warn "[#{self}.#{__method__}]ERROR: #{e}"
end
}
}
end
end

Expand Down

0 comments on commit 8fd2956

Please sign in to comment.