зеркало из https://github.com/github/ruby.git
sample/timeout.rb: fix warnings
warning: Object#timeout is deprecated, use Timeout.timeout instead. [ci skip] git-svn-id: svn+ssh://ci.ruby-lang.org/ruby/trunk@62780 b2dd03c8-39d4-4d8f-98ff-823fe69b080e
This commit is contained in:
Родитель
8a8f542c43
Коммит
23358107f9
|
@ -5,27 +5,27 @@ def progress(n = 5)
|
|||
puts "never reach"
|
||||
end
|
||||
|
||||
p timeout(5) {
|
||||
p Timeout.timeout(5) {
|
||||
45
|
||||
}
|
||||
p timeout(5, Timeout::Error) {
|
||||
p Timeout.timeout(5, Timeout::Error) {
|
||||
45
|
||||
}
|
||||
p timeout(nil) {
|
||||
p Timeout.timeout(nil) {
|
||||
54
|
||||
}
|
||||
p timeout(0) {
|
||||
p Timeout.timeout(0) {
|
||||
54
|
||||
}
|
||||
begin
|
||||
timeout(5) {progress}
|
||||
Timeout.timeout(5) {progress}
|
||||
rescue => e
|
||||
puts e.message
|
||||
end
|
||||
begin
|
||||
timeout(3) {
|
||||
Timeout.timeout(3) {
|
||||
begin
|
||||
timeout(5) {progress}
|
||||
Timeout.timeout(5) {progress}
|
||||
rescue => e
|
||||
puts "never reach"
|
||||
end
|
||||
|
@ -36,7 +36,7 @@ end
|
|||
class MyTimeout < StandardError
|
||||
end
|
||||
begin
|
||||
timeout(2, MyTimeout) {progress}
|
||||
Timeout.timeout(2, MyTimeout) {progress}
|
||||
rescue MyTimeout => e
|
||||
puts e.message
|
||||
end
|
||||
|
|
Загрузка…
Ссылка в новой задаче