Skip to content

Instantly share code, notes, and snippets.

@igrigorik
Created August 26, 2011 14:16
Show Gist options
  • Star 4 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save igrigorik/1173481 to your computer and use it in GitHub Desktop.
Save igrigorik/1173481 to your computer and use it in GitHub Desktop.
require 'em-http'
EM.run do
def dispatch(uri, retries = 0)
h = EM::HttpRequest.new(uri).get
h.callback { |rep| [:success, rep.response]; EM.stop }
h.errback do |rep|
p [:fail, rep]
retries < 3 ? dispatch(uri, retries+1) : EM.stop
end
end
dispatch('http://badhos1212.com/')
end
require 'em-http'
EM.run do
def dispatch(uri, retries = 0)
h = EM::HttpRequest.new(uri).get
h.callback { |rep| [:success, rep.response]; EM.stop }
h.errback do |rep|
p [:fail, rep]
retries < 3 ? dispatch(uri, retries+1) : EM.stop
end
end
dispatch('http://badhos1212.com/')
end
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment