mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
dealt with the timeouts: removed the deadcode for connects, as they no longer proxy it; instead, the selector commands whether the timeout will be triggered, if there are no ready fds; the global handler can also trigger a separate timeout, if this is asked for after the interval was starved, signaling incompletion
This commit is contained in:
parent
6cfe34155a
commit
117acfb6f7
@ -103,6 +103,10 @@ module HTTPX
|
||||
r.unshift(@__r__)
|
||||
|
||||
readers, writers = IO.select(r, w, nil, interval)
|
||||
|
||||
if readers.nil? and writers.nil?
|
||||
raise HTTPX::TimeoutError, "timed out while waiting on select"
|
||||
end
|
||||
rescue IOError, SystemCallError
|
||||
@lock.synchronize do
|
||||
@readers.reject! { |io, _| io.closed? }
|
||||
|
@ -3,13 +3,15 @@
|
||||
require "timeout"
|
||||
|
||||
module HTTPX::Timeout
|
||||
class Global < PerOperation
|
||||
class Global < PerOperation
|
||||
TOTAL_TIMEOUT = 15
|
||||
|
||||
attr_reader :total_timeout
|
||||
|
||||
def initialize(**options)
|
||||
@total_timeout = options.values.reduce(:+, 0)
|
||||
reset_counter
|
||||
def initialize(total_timeout: TOTAL_TIMEOUT)
|
||||
@total_timeout = total_timeout
|
||||
reset_counter
|
||||
@running = false
|
||||
end
|
||||
|
||||
def ==(other)
|
||||
@ -17,19 +19,11 @@ module HTTPX::Timeout
|
||||
@total_timeout == other.total_timeout
|
||||
end
|
||||
|
||||
def connect(&blk)
|
||||
return yield if @connecting
|
||||
reset_timer
|
||||
::Timeout.timeout(@time_left, HTTPX::TimeoutError) do
|
||||
@connecting = true
|
||||
yield
|
||||
end
|
||||
log_time
|
||||
ensure
|
||||
@connecting = false
|
||||
end
|
||||
|
||||
def timeout
|
||||
unless @running
|
||||
reset_timer
|
||||
@running = true
|
||||
end
|
||||
log_time
|
||||
@time_left
|
||||
end
|
||||
@ -52,6 +46,5 @@ module HTTPX::Timeout
|
||||
|
||||
reset_timer
|
||||
end
|
||||
|
||||
end
|
||||
end
|
||||
|
@ -9,10 +9,6 @@ module HTTPX::Timeout
|
||||
other.is_a?(Null)
|
||||
end
|
||||
|
||||
def connect
|
||||
yield
|
||||
end
|
||||
|
||||
def timeout
|
||||
nil
|
||||
end
|
||||
|
@ -31,16 +31,6 @@ module HTTPX::Timeout
|
||||
@operation_timeout == other.operation_timeout &&
|
||||
@keep_alive_timeout == other.keep_alive_timeout
|
||||
end
|
||||
|
||||
def connect
|
||||
return yield if @connecting
|
||||
::Timeout.timeout(@connect_timeout, HTTPX::TimeoutError) do
|
||||
@connecting = true
|
||||
yield
|
||||
end
|
||||
ensure
|
||||
@connecting = false
|
||||
end
|
||||
end
|
||||
end
|
||||
|
||||
|
Loading…
x
Reference in New Issue
Block a user