Because pools are thread-local, any call from a session will be thread-safe.
# 4 separate connections in different pools
4.times.map do |i|
Thread.start { HTTPX.get("https://example.com/#{i}") }
end.join
# same session, different pools
http = HTTPX.accept("application/json")
4.times.map do |i|
Thread.start { http.get("https://example.com/#{i}") }
end.join
However, if you’re using the build_request
functions, they will not:
# same session, different pools
http = HTTPX.accept("application/json")
request = http.build_request(:get, "https://example.com/")
4.times.map do |i|
# DANGEROUS! DON'T DO THIS!
Thread.start { http.send(request) }
end.join
Next: Debugging