Skip to content

Instantly share code, notes, and snippets.

View timlinquist's full-sized avatar

Tim Linquist timlinquist

View GitHub Profile
require 'eventmachine'
require 'em-http'
c = 4
urls = DATA.readlines.map {|s| s.strip }
pending = urls.size
before = Time.now
puts "urls: #{pending}"
puts "concurrency: #{c}"
class CucumberExternalResqueWorker
DEFAULT_STARTUP_TIMEOUT = 1.minute
COUNTER_KEY = "cucumber:counter"
class << self
attr_accessor :pid, :startup_timeout
def start
# Call from a Cucumber support file so it is run on startup
return unless Rails.env.cucumber?
@timlinquist
timlinquist / gist:3660384
Created September 6, 2012 21:08 — forked from steveburkett/gist:3659891
testing ensure
class TolerantFetcher
def self.get(url)
TimeoutNinja.try do
timeout(20) do
begin
handle = open(url)
response = handle.read
ensure
handle.try(:close!) ####### HERE
end