4 ms·
There was recently an article/discussion on async in ruby: https://news.ycombinator.com/item?id=29049881 https://news.ycombinator.com/item?id=29049881 And I t
by e12e 5y ago
There was recently an article/discussion on async in ruby:
https://news.ycombinator.com/item?id=29049881 https://news.ycombinator.com/item?id=29049881
And I think the example is a good one for how doing parallell io can be simple with async tasks/promises:
require "async"
require "open-uri"
Async do |task|
task.async do
URI.open("https://httpbin.org/delay/1.6")
end
task.async do
URI.open("https://httpbin.org/delay/1.6")
end
end
(completes in ~time of slowest request, not sum of requests).
Sure, one could use threads/processes/green threads etc.