Preview Ruby 4.1 is a preview. It can change before the final release. Switch to Ruby 4.0 →
instance method · added in Ruby 3.2
IO#timeout
() -> ::IO::io_timeout
timeout → duration or nil
io.c
View on GitHub ↗
VALUE
rb_io_timeout(VALUE self)
{
rb_io_t *fptr = rb_io_get_fptr(self);
return fptr->timeout;
}
Get the internal timeout duration or nil if it was not set.
Ruby version changes
-
3.2
-
Introduce
IO#timeout=andIO#timeoutwhich can causeIO::TimeoutErrorto be raised if a blocking operation exceeds the specified timeout. [Feature #18630]ExampleSTDIN.timeout = 1 STDIN.read # => Blocking operation timed out! (IO::TimeoutError)
-