Skip to content

Instantly share code, notes, and snippets.

@wkonkel
Created February 14, 2017 18:00
Show Gist options
  • Save wkonkel/ce246e1a9a6e101afa0f75a6ef761829 to your computer and use it in GitHub Desktop.
Save wkonkel/ce246e1a9a6e101afa0f75a6ef761829 to your computer and use it in GitHub Desktop.
@queue = Queue.new
@queue.push(url: '/foo')
workers = (0...CONCURRENCY).map do
Thread.new do
while options = @queue.pop
begin
make_request(options)
rescue => e
retry_request(options)
end
@queue.close if @queue.num_waiting == CONCURRENCY - 1
end
end
end
workers.each(&:join)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment