Project

General

Profile

Actions

Bug #11344

closed

Thread.handle_interrupt(TimeoutError => :never) が効かない

Added by tommy (Masahiro Tomita) over 9 years ago. Updated over 9 years ago.

Status:
Closed
Assignee:
-
Target version:
-
ruby -v:
ruby 2.2.2p95 (2015-04-13 revision 50295) [x86_64-linux]
[ruby-dev:49179]

Description

るりま http://docs.ruby-lang.org/ja/2.2.0/method/Thread/s/handle_interrupt.html によると、Thread.handle_interrupt(TimeoutError => :never)TimeoutError を制御できると書かれていますが、働きません。

require 'timeout'
Thread.handle_interrupt(TimeoutError => :never) do
  timeout(1) do
    sleep 2
    p 'done'
  end
end
#=> sample.rb:4:in `sleep': execution expired (Timeout::Error)

TimeoutError の代わりに Timeout::ExitException を指定すれば働きます。

require 'timeout'
Thread.handle_interrupt(Timeout::ExitException => :never) do
  timeout(1) do
    sleep 2
    p 'done'
  end
end
#=> "done"
#=> sample.rb:2:in `handle_interrupt': execution expired (Timeout::ExitException)

これは意図された挙動でしょうか。

なお、るりまだけじゃなく、thread.c 中のコメントにも同様の記述があります。


Related issues 1 (0 open1 closed)

Related to Ruby master - Misc #19740: Block taking methods can't differentiate between a non-local return and a throwClosedActions
Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0Like0Like0