Actions
Bug #21947
closed`Timeout.timeout` doesn't use `Timeout::ExitException` when Fiber scheduler is in use.
Bug #21947:
`Timeout.timeout` doesn't use `Timeout::ExitException` when Fiber scheduler is in use.
Description
The following example executes successfully after 7 seconds instead of timing out after 2.
require 'async'
require 'net/http'
start = Time.now
Sync do
Timeout.timeout 2 do
Net::HTTP.get(URI 'https://httpbin.org/delay/5')
puts "...request finished, no timeout though; in #{Time.now - start}s"
end
end
puts "Duration: #{Time.now - start}s"
# => ...request finished, no timeout though; in 7.7007s
# Duration: 7.700962s
There are two issues:
-
Net::HTTPrescuesTimeout::Errorand retries. This causes 2s (timeout -> retry) + 5s execution time. -
Timeout.timeoutusesTimeout::ExitExceptionwhen no exception is specified, but the Fiber scheduler code path was not updated.
See https://github.com/socketry/async/issues/448 for more discussion.
Updated by ioquatix (Samuel Williams) about 23 hours ago
See https://github.com/ruby/timeout/pull/97 for a proposed fix.
Updated by Anonymous about 22 hours ago
- Status changed from Open to Closed
Applied in changeset git|f315d250b44e75a1a69f4a05b293dcc701377689.
[ruby/timeout] Compatibility with Fiber scheduler.
(https://github.com/ruby/timeout/pull/97)
[Bug #21947]
Actions