Created
March 5, 2012 01:36
-
-
Save kimoto/1975905 to your computer and use it in GitHub Desktop.
parallel + retry-handlerのサンプルコード
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
Parallel.each(last_infos, :in_threads => 4){ |last_info| | |
begin | |
Proc.new do | |
timeout(20) do | |
Peercast::Screenshot.new(last_info.url).download_to(download_path) | |
end | |
last_info.capture = download_path | |
last_info.save | |
end.retry(:max => 3, :accept_exception => Timeout::Error, :logger => Logger.new(STDERR)) | |
rescue RetryOverError | |
STDERR.puts "reach retry max count" | |
rescue => ex | |
STDERR.puts "other error" | |
STDERR.puts ex | |
end | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment