mirror of
https://github.com/HoneyryderChuck/httpx.git
synced 2025-08-10 00:01:27 -04:00
introducing the ConnectTimeoutError, releasing it on timeout errors on channels when the channel is still connecting
This commit is contained in:
parent
03376524fe
commit
d9c7edceea
@ -141,6 +141,10 @@ module HTTPX
|
||||
end
|
||||
end
|
||||
|
||||
def connecting?
|
||||
@state == :idle
|
||||
end
|
||||
|
||||
def interests
|
||||
return :w if @state == :idle
|
||||
readable = !@read_buffer.full?
|
||||
|
@ -32,8 +32,13 @@ module HTTPX
|
||||
monitor.interests = channel.interests
|
||||
end
|
||||
end
|
||||
rescue TimeoutError,
|
||||
Errno::ECONNRESET,
|
||||
rescue TimeoutError => timeout_error
|
||||
@channels.each do |ch|
|
||||
error = timeout_error
|
||||
error = error.to_connection_error if ch.connecting?
|
||||
ch.emit(:error, error)
|
||||
end
|
||||
rescue Errno::ECONNRESET,
|
||||
Errno::ECONNABORTED,
|
||||
Errno::EPIPE => ex
|
||||
@channels.each do |ch|
|
||||
|
@ -5,7 +5,15 @@ module HTTPX
|
||||
|
||||
UnsupportedSchemeError = Class.new(Error)
|
||||
|
||||
TimeoutError = Class.new(Error)
|
||||
TimeoutError = Class.new(Error) do
|
||||
def to_connection_error
|
||||
ex = ConnectTimeoutError.new(message)
|
||||
ex.set_backtrace(backtrace)
|
||||
ex
|
||||
end
|
||||
end
|
||||
|
||||
ConnectTimeoutError = Class.new(TimeoutError)
|
||||
|
||||
ResolveError = Class.new(Error)
|
||||
|
||||
|
@ -119,6 +119,10 @@ module HTTPX
|
||||
@pending << [request, args]
|
||||
end
|
||||
|
||||
def connecting?
|
||||
super || @state == :connecting || @state == :connected
|
||||
end
|
||||
|
||||
def to_io
|
||||
case @state
|
||||
when :idle
|
||||
|
Loading…
x
Reference in New Issue
Block a user