るりまサーチ

最速Rubyリファレンスマニュアル検索!
21件ヒット [1-21件を表示] (0.058秒)

別のキーワード

  1. _builtin printf
  2. kernel printf
  3. stringio printf
  4. io printf
  5. buffering printf

ライブラリ

モジュール

検索結果

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (19.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...end

printf
"%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外を発生させるタイムアウト
#!/usr/bin/env ruby

require 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep
(30...
...id
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: shell execution."
Process.kill('SIGINT', pid)
printf
"[result]\t%s", com.read
com.close unless com.nil?
end

#止まっているか確認する。
#system("ps au")...

Timeout.#timeout(sec, exception_class, message) {|i| ... } -> object (19.0)

ブロックを sec 秒の期限付きで実行します。 ブロックの実行時間が制限を過ぎたときは例外 Timeout::Error が発生します。

...end

printf
"%d: pi = %f\n", min[0] + min[1], min[0]*4.0/(min[0]+min[1])
#例
#=> 417519: pi = 3.141443

例 独自の例外を発生させるタイムアウト
#!/usr/bin/env ruby

require 'timeout'

class MYError < Exception;end
begin
Timeout.timeout(5, MYError) {
sleep
(30...
...id
while line = com.gets
print line
end
}
rescue Timeout::Error => err
puts "timeout: shell execution."
Process.kill('SIGINT', pid)
printf
"[result]\t%s", com.read
com.close unless com.nil?
end

#止まっているか確認する。
#system("ps au")...