Skip to content

Instantly share code, notes, and snippets.

@alexcharlie
Created July 22, 2008 18:12
Show Gist options
  • Save alexcharlie/1174 to your computer and use it in GitHub Desktop.
Save alexcharlie/1174 to your computer and use it in GitHub Desktop.
require 'rubygems'
require 'rfacebook'
RAILS_ROOT = File.expand_path(File.dirname(__FILE__) + '/..') unless defined? RAILS_ROOT
RAILS_ENV = ENV['RAILS_ENV'] || 'development' unless defined? RAILS_ENV
require File.join(RAILS_ROOT, 'config', 'initializers', 'starling')
ConfigFace = YAML.load_file(File.join(RAILS_ROOT, 'config', 'facebook.yml'))[RAILS_ENV]
def worker_task(task, &block)
runs = 0
desc "worker task: #{task}"
task "ffs:#{task}" do
@fbsession = RFacebook::FacebookWebSession.new(ConfigFace['key'], ConfigFace['secret'])
loop do
sleep 0.1
block.call rescue nil
@fbsession.instance_variable_set(:@expired, false)
# STDOUT.print('.');STDOUT.flush
runs += 1
if runs > 100
runs = 0
GC.start
end
end
end
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment