begin
Timeout.timeout(20) do
a = gets()
end
rescue Timeout::Error
puts "Timeout. 20 seconds gone, etc"
end
Fred
···
Le 14 juillet à 08:22, Raveendran .P a écrit :
Need:
a=gets() is waiting for input. I need to wait only 20 seconds.
--
What would be the point of cyphering messages that very clever enemies
couldn't break? You'd end up not knowing what they thought you thought
they were thinking... (Terry Pratchett, in The Fifth Elephant)
require 'timeout'
a = nil
begin
puts "Print your age"
Timeout.timeout(20) do
a = gets
end
rescue Timeout::Error
puts "Timeout. 20 Seconds Gone. Please re-run the Applciation"
end
# Warning: like most programs, this may not work as desired under
Windows
require 'timeout'
a = nil
begin
puts "Print your age"
Timeout.timeout(20) do
a = gets
end
rescue Timeout::Error
puts "Timeout. 20 Seconds Gone. Please re-run the Applciation"
end
# Warning: like most programs, this may not work as desired under
Windows
require 'timeout'
a = nil
begin
puts "Print your age"
Timeout.timeout(20) do
a = gets
end
rescue Timeout::Error
puts "Timeout. 20 Seconds Gone. Please re-run the Applciation"
end
# Warning: like most programs, this may not work as desired under
Windows
IIRC, the last time I tried that on Windows (a while back) the select
returned on the first char and then gets acted as usual, blocking until EOL.
I would like to know if that actually works.
Ammar
···
On Wed, Jul 14, 2010 at 12:07 PM, Michael Fellinger <m.fellinger@gmail.com>wrote: