Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Problem with nested timeouts in ruby over system calls

I ran into this weird issue while working with ruby(on rails) time outs. This time out

timeout(10) do
 //some code involving http calls that takes more than 10 seconds
end

is not working. But this timeout

timeout(20) do
 timeout(10) do
   //some code involving http calls that takes more than 10 seconds
 end
end

times out after 20 seconds. I read that timeout in ruby wont work properly if it involves system calls. If that be the case then any number of nested timeout should also not work. Why would this work on the second timeout?

The link I referred: http://ph7spot.com/musings/system-timer

like image 475
ET's Avatar asked May 23 '26 12:05

ET's


1 Answers

You might have better luck using a combination of timeout and terminator to do this sort of thing.

One of the known deficiencies of the timeout method is it's not always strictly enforced and many things can block it.

like image 186
tadman Avatar answered May 26 '26 06:05

tadman



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!