Project

General

Profile

Actions

Bug #4681

closed

Timeout.timeout doesn't actually time out?

Added by meta (mathew murphy) over 10 years ago. Updated about 10 years ago.

Status:
Rejected
Priority:
Normal
Target version:
ruby -v:
1.9.2p180
Backport:
[ruby-core:36153]

Description

Documentation for Timeout says "A way of performing a potentially long-running operation in a thread, and terminating its execution if it hasn‘t finished by a fixed amount of time."

This doesn't actually seem to be what it does.

Example code:

#!/usr/bin/ruby

encoding: UTF-8

require 'open3'

require 'timeout'

puts "Time out after 2 seconds. Count them..."

result = Timeout.timeout(2) do

stdin, stdout, stderr = Open3.capture3("sleep 30")

output = stdout.read + "\n" + stderr.read

end

On my systems, this doesn't time out after 2 seconds. Instead, it runs for 30 seconds, and then throws an error saying it took longer than 2 seconds.

Actions

Also available in: Atom PDF