Method: Facebooker::Service.with_async

Defined in:
lib/facebooker/service.rb

.with_async(&proc) ⇒ Object

Process all calls to Facebook in th block asynchronously nil will be returned from all calls and no results will be parsed. This is mostly useful for sending large numbers of notifications or sending a lot of profile updates

for example:

User.find_in_batches(:batch_size => 200) do |users|
  Faceboooker::Service.with_async do
    users.each {|u| u.facebook_session.send_notification(...)}
  end
end

Note: You shouldn’t make more than about 200 api calls in a with_async block or you might exhaust all filehandles.

This functionality require the typhoeus gem



52
53
54
55
# File 'lib/facebooker/service.rb', line 52

def self.with_async(&proc)
  block_with_process = Proc.new { proc.call ; process_async}
  with_service(Facebooker::Service::TyphoeusMultiService.new,&block_with_process)
end