Issue #17470 has been updated by jsc (Justin Collins).


It appears that `Timeout.timeout` does not work when a Fiber scheduler is set, regardless of the implementation, even when Fibers are not explicitly in use.

Simple example using the [sample scheduler](https://github.com/ruby/ruby/blob/441cd156e0e6fc5161440c782901861fbc43af80/test/fiber/scheduler.rb#L1):

``` ruby
require 'timeout'
require 'fiber'
require_relative 'scheduler'

scheduler = Scheduler.new
Fiber.set_scheduler scheduler

Timeout.timeout 1 do
  puts "hello"
end
```

This code will print "hello" then hang.

----------------------------------------
Bug #17470: Introduce non-blocking `Timeout.timeout`
https://bugs.ruby-lang.org/issues/17470#change-89550

* Author: ioquatix (Samuel Williams)
* Status: Open
* Priority: Normal
* Backport: 2.5: UNKNOWN, 2.6: UNKNOWN, 2.7: UNKNOWN
----------------------------------------
In this bug report, user complained that `Timeout.timeout` does not work correctly with scheduler: https://github.com/socketry/async-io/issues/43

We should introduce non-blocking timeout.

I propose the following:

```
rb_fiber_scheduler_with_timeout(VALUE scheduler, VALUE timeout, VALUE block)
```

We can directly modify `Timeout.timeout` to invoke this hook.



-- 
https://bugs.ruby-lang.org/

Unsubscribe: <mailto:ruby-core-request / ruby-lang.org?subject=unsubscribe>
<http://lists.ruby-lang.org/cgi-bin/mailman/options/ruby-core>