Skip to content

Instantly share code, notes, and snippets.

@kimoto
Created March 5, 2012 01:36
Show Gist options
  • Star 1 You must be signed in to star a gist
  • Fork 1 You must be signed in to fork a gist
  • Save kimoto/1975905 to your computer and use it in GitHub Desktop.
Save kimoto/1975905 to your computer and use it in GitHub Desktop.
parallel + retry-handlerのサンプルコード
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