Forum: Ruby Timeout

Announcement (2017-05-07): www.ruby-forum.com is now read-only since I unfortunately do not have the time to support and maintain the forum any more. Please see rubyonrails.org/community and ruby-lang.org/en/community for other Rails- und Ruby-related community platforms.
F3b786a23390451fa67108781b0c8fed?d=identicon&s=25 unknown (Guest)
on 2006-02-07 08:20
(Received via mailing list)
Does Ruby's Timeout know about time spent outside of Ruby's
interpreter?

For instance, will it call Timeout in the model of long syscalls (ie,
blocking io which is taking too long).

If not, what is the best way to tell Ruby to abort a syscall after x
seconds.  (I couldn't find a way of setting an alarm handler).
58479f76374a3ba3c69b9804163f39f4?d=identicon&s=25 Eric Hodel (Guest)
on 2006-02-07 08:44
(Received via mailing list)
On Feb 6, 2006, at 11:18 PM, eastcoastcoder@gmail.com wrote:

> Does Ruby's Timeout know about time spent outside of Ruby's
> interpreter?

Did you try it?  It is really, really easy, especially with irb.

> For instance, will it call Timeout in the model of long syscalls (ie,
> blocking io which is taking too long).

require 'timeout'
require 'socket'

s = TCPSocket.new 'localhost', 80
Timeout.timeout 5 do s.read end

--
Eric Hodel - drbrain@segment7.net - http://segment7.net
This implementation is HODEL-HASH-9600 compliant

http://trackmap.robotcoop.com
F3b786a23390451fa67108781b0c8fed?d=identicon&s=25 unknown (Guest)
on 2006-02-07 10:09
(Received via mailing list)
Thanks for the help.

For anyone who's reading this's reference, the answer is that Timeout
does timeout in the middle of syscalls.
This topic is locked and can not be replied to.