From: mathew murphy Date: 2011-12-08T13:37:25+09:00 Subject: [ruby-core:41540] [ruby-trunk - Bug #4681] Timeout.timeout doesn't actually time out? Issue #4681 has been updated by mathew murphy. Just noting for the benefit of anyone else passing by that I posted a way to do popen3 with timeout at https://gist.github.com/1032297 ---------------------------------------- Bug #4681: Timeout.timeout doesn't actually time out? http://redmine.ruby-lang.org/issues/4681 Author: mathew murphy Status: Rejected Priority: Normal Assignee: Akira Tanaka Category: Target version: 1.9.3 ruby -v: 1.9.2p180 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. -- http://redmine.ruby-lang.org