4件ヒット
[1-4件を表示]
(0.011秒)
検索結果
先頭4件
-
Timeout
:: Error (18007.0) -
timeout で定義される例外クラスです。 関数 timeout がタイムアウトすると発生します。
...timeout で定義される例外クラスです。
関数 timeout がタイムアウトすると発生します。
timeout を使うライブラリを作成する場合は、ユーザが指定した
timeout を捕捉しないようにライブラリ内で Timeout::Error のサブクラスを
定義......'timeout.rb'
class Foo
FooTimeoutError = Class.new(Timeout::Error)
def longlongtime_method
Timeout.timeout(100, FooTimeoutError) {
...
}
end
end
==> main.rb <==
require 'foo'
Timeout.timeout... -
TimeoutError (18007.0)
-
Alias of Timeout::Error
...Alias of Timeout::Error... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (61.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...c 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはい......ウト
require 'timeout'
def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end
end
t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end
printf "%......るタイムアウト
#!/usr/bin/env ruby
require 'timeout'
class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts "MYError"
puts err
end
=== 注意
timeout による割り込みは Thread によって実現さ... -
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (61.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...c 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
Timeout::Error が発生します。
exception_class を指定した場合には Timeout::Error の代わりに
その例外が発生します。
ブロックパラメータ i は sec がはい......ウト
require 'timeout'
def calc_pi(min)
loop do
x = rand
y = rand
x**2 + y**2 < 1.0 ? min[0] += 1 : min[1] += 1
end
end
t = 5
min = [ 0, 0]
begin
Timeout.timeout(t){
calc_pi(min)
}
rescue Timeout::Error
puts "timeout"
end
printf "%......るタイムアウト
#!/usr/bin/env ruby
require 'timeout'
class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep(30)
}
rescue MYError => err
puts "MYError"
puts err
end
=== 注意
timeout による割り込みは Thread によって実現さ...