mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-10-04 00:00:37 -04:00
Merge branch 'gh-issue-3' into 'master'
do not loop forever if there are no connections to listen nor any timer See merge request honeyryderchuck/httpx!177
This commit is contained in:
commit
938d69aed7
@ -117,6 +117,13 @@ class HTTPX::Selector
|
||||
end
|
||||
|
||||
def select(interval, &block)
|
||||
# do not cause an infinite loop here.
|
||||
#
|
||||
# this may happen if timeout calculation actually triggered an error which causes
|
||||
# the connections to be reaped (such as the total timeout error) before #select
|
||||
# gets called.
|
||||
return if interval.nil? && @selectables.empty?
|
||||
|
||||
return select_one(interval, &block) if @selectables.size == 1
|
||||
|
||||
select_many(interval, &block)
|
||||
|
19
regression_tests/bug_0_18_2_test.rb
Normal file
19
regression_tests/bug_0_18_2_test.rb
Normal file
@ -0,0 +1,19 @@
|
||||
# frozen_string_literal: true
|
||||
|
||||
require "test_helper"
|
||||
require "support/http_helpers"
|
||||
require "support/minitest_extensions"
|
||||
|
||||
class Bug_0_18_2_Test < Minitest::Test
|
||||
include HTTPHelpers
|
||||
|
||||
def test_no_loop_forever_when_total_timeout_on_persistent
|
||||
session = HTTPX.plugin(:persistent).with_timeout(total_timeout: 1)
|
||||
|
||||
response1 = session.get("https://#{httpbin}/get")
|
||||
sleep 2
|
||||
response2 = session.get("https://#{httpbin}/get")
|
||||
verify_status(response1, 200)
|
||||
verify_status(response2, 200)
|
||||
end
|
||||
end
|
Loading…
x
Reference in New Issue
Block a user