lib/httpx/selector.rb in httpx-0.16.1 vs lib/httpx/selector.rb in httpx-0.17.0
- old
+ new
@@ -84,11 +84,11 @@
# TODO: what to do if there are no selectables?
readers, writers = IO.select(r, w, nil, interval)
- raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") if readers.nil? && writers.nil?
+ raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") if readers.nil? && writers.nil? && interval
rescue IOError, SystemCallError
@selectables.reject!(&:closed?)
retry
end
@@ -107,19 +107,21 @@
end
def select_one(interval)
io = @selectables.first
+ return unless io
+
interests = io.interests
result = case interests
when :r then io.to_io.wait_readable(interval)
when :w then io.to_io.wait_writable(interval)
when :rw then io.to_io.wait(interval, :read_write)
when nil then return
end
- raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") unless result
+ raise HTTPX::TimeoutError.new(interval, "timed out while waiting on select") unless result || interval.nil?
yield io
rescue IOError, SystemCallError
@selectables.reject!(&:closed?)
raise unless @selectables.empty?