Created
November 2, 2015 22:35
-
-
Save keshihoriuchi/01b7bc38654d1e30639e to your computer and use it in GitHub Desktop.
Thread.abort_on_exceptionを書き換えるコードを安全に並列実行する
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
require 'parallel' | |
require 'retryable' | |
res = Parallel.map((1..10).to_a, in_threads: 10) do |a| | |
Retryable.retryable(tries: 50) do | |
Parallel.map([a], in_processes: 1) do |b| | |
Thread.current.abort_on_exception = true | |
exit if [1, 2].sample == 1 | |
b + 1 | |
end[0] | |
end | |
end | |
p res |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment