Timeout issue making system call in Ruby on Windows XP -


the following code

require 'timeout'  begin   timeout(20)              # line 4     result = `hostname`   end                         # line 6 rescue timeout::error   puts "timeout"   exit end  puts "result:" + result       # line 12 

throws error

issue.rb:12:in <main>': undefined local variable or methodresult' main:object (nameerror)

but if comment out timeout element (lines 4 , 6), works fine. have tried using io.popen, io.select etc none of helps. i've used timeout technique in many other areas , worked fine.

it doesn't appear related timeout value have experimented larger , smaller values.

am using ruby 1.92 on windows xp. appreciated.

p.s. original problem not running "hostname" more complex sql server batch job. bonus point, long running system task exceeded timeout automatically killed? have read lots of posts timeout library not honouring timeouts when busy running system tasks?

the result variable being defined inside timeout block, it's not visible in outer scope. should initialize before:

result = nil  begin   timeout(20)              # line 4     result = `hostname`   end                         # line 6 rescue timeout::error ... 

Comments

Popular posts from this blog

javascript - Enclosure Memory Copies -

php - Replacing tags in braces, even nested tags, with regex -