Backport #915
closedthreadのQueue#popでまっているときにTimeout.timeoutによるタイムアウトが発生したあとQueue#pushでささる
Description
=begin
thread の Queue#pop でキューへの追加をまっているときに、
Timeout.timeout によるタイムアウトが発生したときの挙動がrubyのバージョンによって異なり、
以下のようになりました。
- 1.8.5 と 1.9 は同じ
- 1.8.6 と 1.8.7 は同じ
- 1.8ブランチの最新(r20895) はどれとも違う
なお、動作を確認した環境は Debian GNU/Linux 4.0(Etch) です。
----- timeout.rb: ここから -----
require "timeout"
require "thread"
queue = Queue.new
t = Thread.start {
begin
sleep(1000)
rescue Exception
end
}
begin
Timeout.timeout(2) do
puts "waiting pop..."
queue.pop
end
rescue Timeout::Error
p $!
end
puts "pushing..."
queue.push(1)
puts "pushed."
puts "poping..."
p queue.pop
puts "poped."
t.raise(Exception)
t.join
----- timeout.rb: ここまで -----
----- 実行結果: ここから -----
havana$ ruby -v ~/work/acts/Infocast-EAR/work/timeout.rb
ruby 1.8.5 (2006-08-25) [i486-linux]
waiting pop...
#<Timeout::Error: execution expired>
pushing...
pushed.
poping...
1
poped.
havana$ ~/local/ruby_1_8_6/bin/ruby186 -v ~/work/acts/Infocast-EAR/work/timeout.rb
ruby 1.8.6 (2008-08-11 patchlevel 287) [i686-linux]
waiting pop...
#<Timeout::Error: execution expired>
pushing...
(ここでささる)
havana$ ~/local/ruby_1_8_7/bin/ruby187 -v ~/work/acts/Infocast-EAR/work/timeout.rb
ruby 1.8.7 (2008-11-11 patchlevel 73) [i686-linux]
waiting pop...
#<Timeout::Error: execution expired>
pushing...
(ここでささる)
havana$ ~/local/ruby_1_8/bin/ruby18 -v ~/work/acts/Infocast-EAR/work/timeout.rb
ruby 1.8.7 (2008-12-21 revision 20895) [i686-linux]
waiting pop...
#<Timeout::Error: execution expired>
pushing...
/home/kouji/work/acts/Infocast-EAR/work/timeout.rb:22:in `push': thread 0xb7dca160 tried to join itself (ThreadError)
from /home/kouji/work/acts/Infocast-EAR/work/timeout.rb:22
havana$ ruby19trunk -v ~/work/acts/Infocast-EAR/work/timeout.rb
ruby 1.9.0 (2008-08-01 revision 18308) [i686-linux]
waiting pop...
#<Timeout::Error: execution expired>
pushing...
pushed.
poping...
1
poped.
----- 実行結果: ここまで -----
=end
Updated by shyouhei (Shyouhei Urabe) almost 16 years ago
- Assignee set to nobu (Nobuyoshi Nakada)
- ruby -v set to ruby 1.8.7 (2008-11-11 patchlevel 73) [i686-linux]
=begin
=end
Updated by nobu (Nobuyoshi Nakada) almost 16 years ago
- Status changed from Open to Closed
=begin
Applied at changeset r22011.
=end
Updated by nobu (Nobuyoshi Nakada) almost 16 years ago
- Category set to ext
- Status changed from Closed to Assigned
- Assignee changed from nobu (Nobuyoshi Nakada) to shyouhei (Shyouhei Urabe)
=begin
=end
Updated by shyouhei (Shyouhei Urabe) almost 16 years ago
- Status changed from Assigned to Closed
- % Done changed from 0 to 100
=begin
Applied in changeset r23049.
=end