Open skrbhn opened 8 years ago
I'm not 100% sure if related to this issue, or another issue entirely -- I'm not seeing any unknown error
but as far as I can tell, either I'm misunderstanding the purpose of kill
, or it simply doesn't work
def timeout(time, &blk)
t2 = Thread.new(&blk)
t1 = Thread.new do
Thread.sleep(time)
t2.kill
puts "t2 should be killed; alive = #{t2.alive?}"
end
t2.join
puts "t2 finished"
t1.kill
end
timeout(2) do
puts "waiting for char"
char = STDIN.getc
puts "this shouldn't run"
end
puts "after timeout"
prints:
waiting for char
t2 should be killed; alive = true
and if the enter key is pressed after waiting:
waiting for char
t2 should be killed; alive = true
this shouldn't run
t2 finished
after timeout
You may be using https://github.com/ksss/mruby-signal, it conflicts with mruby-thread
Even if you do not use mruby-signal
functions, the very fact it is compiled into your mruby breaks killing threads
After 10 seconds, it's closed by a unkown error which is from os.