gist: 1174 Download_button fork
public
Public Clone URL: git://gist.github.com/1174.git
Ruby
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
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

Owner

alexcharlie

Revisions