Timeout

E

eastcoastcoder

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).
 
E

Eric Hodel

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
 
E

eastcoastcoder

Thanks for the help.

For anyone who's reading this's reference, the answer is that Timeout
does timeout in the middle of syscalls.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,744
Messages
2,569,483
Members
44,903
Latest member
orderPeak8CBDGummies

Latest Threads

Top