I have an extremely simple setup that tests the rails3 ActiveSupport::Notifications.
By reading the documentation, the ActiveSupport::Notifications.subscribe bit should perform it's operations asynchronously. Apparently this is not the case.
Example:
ActiveSupport::Notifications.subscribe "some.channel" do |name, start, finish, id, payload|
# do expensive task
sleep(10)
end
ActiveSupport::Notifications.instrument "some.channel" #=> will return 10 seconds later
I was under the impression that ActiveSupport::Notifications.instrument "some.channel" would return right away and let the expensive task do expensive stuff. Otherwise I could just call the expensive task directly, without using a subscriber.
The documentation is also stating that there could be multiple subscribers. In that case I would get blocked until all other subscribers executed their code.
Is this right? If it is, can someone please explain what does this line from http://api.rubyonrails.org/classes/ActiveSupport/Notifications.html mean?
The block will be called asynchronously whenever someone instruments “render”: