41件ヒット
[1-41件を表示]
(0.009秒)
別のキーワード
検索結果
先頭4件
-
TimeoutError (38001.0)
-
Alias of Timeout::Error
...Alias of Timeout::Error... -
Timeout
. # timeout(sec , exception _ class = nil) {|i| . . . } -> object (13.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
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......の箇所)で TimeoutError 例外があがっています。
例 timeout が割り込めない
require 'timeout'
require 'socket'
t = 0.1
start = Time.now
begin
Timeout.timeout(t) {
p TCPSocket.gethostbyname("www.ruby-lang.org")
# (A)
}
ensure
p Time.now - start... -
Timeout
. # timeout(sec , exception _ class , message) {|i| . . . } -> object (13.0) -
ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。
...sec 秒の期限付きで実行します。
ブロックの実行時間が制限を過ぎたときは例外
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......の箇所)で TimeoutError 例外があがっています。
例 timeout が割り込めない
require 'timeout'
require 'socket'
t = 0.1
start = Time.now
begin
Timeout.timeout(t) {
p TCPSocket.gethostbyname("www.ruby-lang.org")
# (A)
}
ensure
p Time.now - start... -
Timeout
:: Error (13.0) -
timeout で定義される例外クラスです。 関数 timeout がタイムアウトすると発生します。
...timeout で定義される例外クラスです。
関数 timeout がタイムアウトすると発生します。
timeout を使うライブラリを作成する場合は、ユーザが指定した
timeout を捕捉しないようにライブラリ内で TimeoutError のサブクラスを
定義......quire 'timeout.rb'
class Foo
FooTimeoutError = Class.new(TimeoutError)
def longlongtime_method
Timeout.timeout(100, FooTimeoutError) {
...
}
end
end
==> main.rb <==
require 'foo'
timeout(5)......{
Foo.new.longlongtime_method
}...