mirror of
https://github.com/ruby/ruby.git
synced 2022-11-09 12:17:21 -05:00
merge revision(s) 51213: [Backport #11344]
* lib/timeout.rb (ExitException): removed internal exception class and use Timeout::Error instead, as using throw/catch to isolate each timeouts now. [ruby-dev:49179] [Bug #11344] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/branches/ruby_2_1@51603 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
parent
9580200f7d
commit
ccef579aee
4 changed files with 35 additions and 7 deletions
12
ChangeLog
12
ChangeLog
|
|
@ -1,3 +1,15 @@
|
|||
Mon Aug 17 16:51:45 2015 CHIKANAGA Tomoyuki <nagachika@ruby-lang.org>
|
||||
|
||||
* lib/timeout.rb (ExitException): leave Timeout::ExitException as an
|
||||
alias of Timeout::Error for backward compatibility in stable branch.
|
||||
[ruby-dev:49179] [Bug #11344]
|
||||
|
||||
Mon Aug 17 16:51:45 2015 Nobuyoshi Nakada <nobu@ruby-lang.org>
|
||||
|
||||
* lib/timeout.rb (ExitException): removed internal exception class
|
||||
and use Timeout::Error instead, as using throw/catch to isolate
|
||||
each timeouts now. [ruby-dev:49179] [Bug #11344]
|
||||
|
||||
Mon Aug 17 16:49:00 2015 Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
|
||||
|
||||
* test/net/http/test_httpresponse.rb
|
||||
|
|
|
|||
|
|
@ -24,8 +24,6 @@
|
|||
module Timeout
|
||||
# Raised by Timeout#timeout when the block times out.
|
||||
class Error < RuntimeError
|
||||
end
|
||||
class ExitException < ::Exception # :nodoc:
|
||||
attr_reader :thread
|
||||
|
||||
def self.catch(*args)
|
||||
|
|
@ -48,6 +46,7 @@ module Timeout
|
|||
self
|
||||
end
|
||||
end
|
||||
ExitException = Error
|
||||
|
||||
# :stopdoc:
|
||||
THIS_FILE = /\A#{Regexp.quote(__FILE__)}:/o
|
||||
|
|
@ -103,7 +102,7 @@ module Timeout
|
|||
bt = e.backtrace
|
||||
end
|
||||
else
|
||||
bt = ExitException.catch(message, &bl)
|
||||
bt = Error.catch(message, &bl)
|
||||
end
|
||||
rej = /\A#{Regexp.quote(__FILE__)}:#{__LINE__-4}\z/o
|
||||
bt.reject! {|m| rej =~ m}
|
||||
|
|
|
|||
|
|
@ -63,9 +63,9 @@ class TestTimeout < Test::Unit::TestCase
|
|||
end
|
||||
|
||||
def test_exit_exception
|
||||
assert_raise_with_message(Timeout::ExitException, "boon") do
|
||||
Timeout.timeout(10, Timeout::ExitException) do
|
||||
raise Timeout::ExitException, "boon"
|
||||
assert_raise_with_message(Timeout::Error, "boon") do
|
||||
Timeout.timeout(10, Timeout::Error) do
|
||||
raise Timeout::Error, "boon"
|
||||
end
|
||||
end
|
||||
end
|
||||
|
|
@ -80,4 +80,21 @@ class TestTimeout < Test::Unit::TestCase
|
|||
Timeout.timeout(0.01) {e.next}
|
||||
end
|
||||
end
|
||||
|
||||
def test_handle_interrupt
|
||||
bug11344 = '[ruby-dev:49179] [Bug #11344]'
|
||||
ok = false
|
||||
assert_raise(Timeout::Error) {
|
||||
Thread.handle_interrupt(Timeout::Error => :never) {
|
||||
Timeout.timeout(0.01) {
|
||||
sleep 0.2
|
||||
ok = true
|
||||
Thread.handle_interrupt(Timeout::Error => :on_blocking) {
|
||||
sleep 0.2
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
assert(ok, bug11344)
|
||||
end
|
||||
end
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
#define RUBY_VERSION "2.1.7"
|
||||
#define RUBY_RELEASE_DATE "2015-08-17"
|
||||
#define RUBY_PATCHLEVEL 386
|
||||
#define RUBY_PATCHLEVEL 387
|
||||
|
||||
#define RUBY_RELEASE_YEAR 2015
|
||||
#define RUBY_RELEASE_MONTH 8
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue