Created
September 17, 2012 21:04
-
-
Save cktricky/3739762 to your computer and use it in GitHub Desktop.
Celluloid Test
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env ruby | |
require 'celluloid' | |
require 'net/http' | |
class Fetcher | |
include Celluloid | |
def get(url) | |
puts "requesting url #{url}" | |
response = Net::HTTP.get URI(url) | |
puts response | |
rescue Exception => e | |
puts e.to_s | |
end | |
end | |
urls = Array.new(1000, "http://www.cnn.com") | |
pool = Fetcher.pool(size: 64); urls.map { |url| pool.future.get(url) }.map(&:value) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment