1
0
Fork 0
mirror of https://github.com/ruby/ruby.git synced 2022-11-09 12:17:21 -05:00

normalize reference to Timeout::Error

From: John Bachir <j@jjb.cc>

* bootstraptest/test_io.rb (assert_finish):
  normalize rescue for Timeout::Error
* lib/net/ftp.rb (Net#read_timeout): ditto for doc
* lib/resolv.rb (Resolv::ResolvTimeout): ditto for subclass
* lib/webrick/httprequest.rb (_read_data): ditto for rescue
* sample/timeout.rb (p timeout): ditto for call
* test/drb/drbtest.rb (test_06_timeout): ditto
* test/ruby/test_readpartial.rb (test_open_pipe): ditto
* test/thread/test_queue.rb (test_queue_thread_raise): ditto
* thread.c (rb_thread_s_handle_interrupt): ditto for doc
  [ruby-core:65481] [misc #10339]

TimeoutError is a legacy constant, Timeout::Error is the canonical constant.
This patch normalizes all code and comments to reference Timeout::Error.

git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@47838 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
normal 2014-10-07 20:00:09 +00:00
parent 554577015f
commit 9bb7dfa247
10 changed files with 35 additions and 21 deletions

View file

@ -1,3 +1,17 @@
Wed Oct 8 04:58:48 2014 John Bachir <j@jjb.cc>
* bootstraptest/test_io.rb (assert_finish):
normalize rescue for Timeout::Error
* lib/net/ftp.rb (Net#read_timeout): ditto for doc
* lib/resolv.rb (Resolv::ResolvTimeout): ditto for subclass
* lib/webrick/httprequest.rb (_read_data): ditto for rescue
* sample/timeout.rb (p timeout): ditto for call
* test/drb/drbtest.rb (test_06_timeout): ditto
* test/ruby/test_readpartial.rb (test_open_pipe): ditto
* test/thread/test_queue.rb (test_queue_thread_raise): ditto
* thread.c (rb_thread_s_handle_interrupt): ditto for doc
[ruby-core:65481] [misc #10339]
Wed Oct 8 04:38:29 2014 Rei Odaira <Rei.Odaira@gmail.com>
* test/ruby/test_process.rb (TestProcess#test_setsid): AIX

View file

@ -26,7 +26,7 @@ assert_finish 10, %q{
t1.join
t2.join
end
rescue LoadError, TimeoutError, NotImplementedError
rescue LoadError, Timeout::Error, NotImplementedError
end
}, '[ruby-dev:32566]'

View file

@ -103,7 +103,7 @@ module Net
# Number of seconds to wait for one block to be read (via one read(2)
# call). Any number may be used, including Floats for fractional
# seconds. If the FTP object cannot read data in this many seconds,
# it raises a TimeoutError exception. The default value is 60 seconds.
# it raises a Timeout::Error exception. The default value is 60 seconds.
attr_reader :read_timeout
# Setter for the read_timeout attribute.

View file

@ -158,7 +158,7 @@ class Resolv
##
# Indicates a timeout resolving a name or address.
class ResolvTimeout < TimeoutError; end
class ResolvTimeout < Timeout::Error; end
##
# Resolv::Hosts is a hostname resolver that uses the system hosts file.

View file

@ -521,7 +521,7 @@ module WEBrick
}
rescue Errno::ECONNRESET
return nil
rescue TimeoutError
rescue Timeout::Error
raise HTTPStatus::RequestTimeout
end
end

View file

@ -8,7 +8,7 @@ end
p timeout(5) {
45
}
p timeout(5, TimeoutError) {
p timeout(5, Timeout::Error) {
45
}
p timeout(nil) {

View file

@ -190,10 +190,10 @@ module DRbCore
def test_06_timeout
ten = Onecky.new(10)
assert_raise(TimeoutError) do
assert_raise(Timeout::Error) do
@there.do_timeout(ten)
end
assert_raise(TimeoutError) do
assert_raise(Timeout::Error) do
@there.do_timeout(ten)
end
end

View file

@ -50,7 +50,7 @@ class TestReadPartial < Test::Unit::TestCase
w << 'abc'
assert_equal('ab', r.readpartial(2))
assert_equal('c', r.readpartial(2))
assert_raise(TimeoutError) {
assert_raise(Timeout::Error) {
timeout(0.1) { r.readpartial(2) }
}
}
@ -64,7 +64,7 @@ class TestReadPartial < Test::Unit::TestCase
assert_equal("de", r.readpartial(2))
assert_equal("f\n", r.readpartial(4096))
assert_equal("ghi\n", r.readpartial(4096))
assert_raise(TimeoutError) {
assert_raise(Timeout::Error) {
timeout(0.1) { r.readpartial(2) }
}
}

View file

@ -239,7 +239,7 @@ class TestQueue < Test::Unit::TestCase
th1.raise
sleep 0.1
q << :s
assert_nothing_raised(TimeoutError) do
assert_nothing_raised(Timeout::Error) do
timeout(1) { th2.join }
end
ensure

View file

@ -1731,29 +1731,29 @@ handle_interrupt_arg_check_i(VALUE key, VALUE val)
* resource allocation code. Then, the ensure block is where we can safely
* deallocate your resources.
*
* ==== Guarding from TimeoutError
* ==== Guarding from Timeout::Error
*
* In the next example, we will guard from the TimeoutError exception. This
* will help prevent from leaking resources when TimeoutError exceptions occur
* In the next example, we will guard from the Timeout::Error exception. This
* will help prevent from leaking resources when Timeout::Error exceptions occur
* during normal ensure clause. For this example we use the help of the
* standard library Timeout, from lib/timeout.rb
*
* require 'timeout'
* Thread.handle_interrupt(TimeoutError => :never) {
* Thread.handle_interrupt(Timeout::Error => :never) {
* timeout(10){
* # TimeoutError doesn't occur here
* Thread.handle_interrupt(TimeoutError => :on_blocking) {
* # possible to be killed by TimeoutError
* # Timeout::Error doesn't occur here
* Thread.handle_interrupt(Timeout::Error => :on_blocking) {
* # possible to be killed by Timeout::Error
* # while blocking operation
* }
* # TimeoutError doesn't occur here
* # Timeout::Error doesn't occur here
* }
* }
*
* In the first part of the +timeout+ block, we can rely on TimeoutError being
* ignored. Then in the <code>TimeoutError => :on_blocking</code> block, any
* In the first part of the +timeout+ block, we can rely on Timeout::Error being
* ignored. Then in the <code>Timeout::Error => :on_blocking</code> block, any
* operation that will block the calling thread is susceptible to a
* TimeoutError exception being raised.
* Timeout::Error exception being raised.
*
* ==== Stack control settings
*