Skip to content

End of Life Ruby 3.2 has reached end of life and gets no more fixes. Switch to Ruby 4.0 →

instance method · added in Ruby 3.2

IO#timeout

timeout → duration or nil

Get the internal timeout duration or nil if it was not set.

Ruby version changes

  1. 3.2
    • Introduce IO#timeout= and IO#timeout which can cause IO::TimeoutError to be raised if a blocking operation exceeds the specified timeout. [Feature #18630]

      Example
      STDIN.timeout = 1
      STDIN.read # => Blocking operation timed out! (IO::TimeoutError)
      
See also #timeout= #tell #syswrite #to_i also in 4.1 · 4.0 · 3.4 · 3.3