るりまサーチ

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

別のキーワード

  1. timeout timeout
  2. openssl timeout
  3. openssl timeout=
  4. kernel timeout
  5. timeout timeouterror

ライブラリ

クラス

モジュール

キーワード

検索結果

Timeout.#timeout(sec, exception_class = nil) {|i| ... } -> object (35274.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 (35274.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 = nil) {|i| ... } -> object (35273.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 によって実現さ...

Mutex#sleep(timeout = nil) -> Integer (18232.0)

与えられた秒数の間ロックを解除してスリープして、実行後にまたロックします。

...与えられた秒数の間ロックを解除してスリープして、実行後にまたロックします。

@param timeout スリープする秒数を指定します。省略するとスリープし続けます。

@return スリープしていた秒数を返します。

@raise ThreadError...
...グナルを受信した場合などに実行が再
開(spurious wakeup)される場合がある点に注意してください。

//emlist[例][ruby]{
m = Mutex.new
th = Thread.new do
m.lock
m.sleep(2)
end
th.status # => "run"
sleep
1
th.status # => "sleep"
sleep
1
th.status # => false
//}...

Thread::Mutex#sleep(timeout = nil) -> Integer (18232.0)

与えられた秒数の間ロックを解除してスリープして、実行後にまたロックします。

...与えられた秒数の間ロックを解除してスリープして、実行後にまたロックします。

@param timeout スリープする秒数を指定します。省略するとスリープし続けます。

@return スリープしていた秒数を返します。

@raise ThreadError...
...グナルを受信した場合などに実行が再
開(spurious wakeup)される場合がある点に注意してください。

//emlist[例][ruby]{
m = Mutex.new
th = Thread.new do
m.lock
m.sleep(2)
end
th.status # => "run"
sleep
1
th.status # => "sleep"
sleep
1
th.status # => false
//}...
...与えられた秒数の間ロックを解除してスリープして、実行後にまたロックします。

@param timeout スリープする秒数を指定します。省略するとスリープし続けます。

@return タイムアウトした時は nil を、それ以外はスリープし...

絞り込み条件を変える

ruby 1.6 feature (48.0)

ruby 1.6 feature ruby version 1.6 は安定版です。この版での変更はバグ修正がメイン になります。

...するとエラーになっていました。
((<ruby-dev:17155>))

open("|-","r+") {|f|
if f
f.dup.close_write
else
sleep
1
end
}

=> ruby 1.6.7 (2002-03-01) [i586-linux]
-:3:in `close_write': closing non-duplex IO for writing (IOError)...
...修正さ
れました。((<ruby-bugs-ja:PR#223>))

trap(:TERM, "EXIT")

END{
puts "exit"
}

Thread.start { Thread.stop }
sleep


: 2002-04-17: Regexp#inspect

((<ruby-bugs-ja:PR#222>))

p %r{\/}

=> ruby 1.6.7 (2002-03-01) [i586-linux]
/\\//

=> ruby...
...したリゾルバは、timeout の制御が効きます(つまり、名前解
決中にThreadが切替え可能ということです)

require 'resolv'
p Resolv.new.getaddress("www.ruby-lang.org").to_s

=> /usr/local/lib/ruby/1.6/resolv.rb:160: warning: timeout (...) interpreted as me...

NEWS for Ruby 3.0.0 (24.0)

NEWS for Ruby 3.0.0 このドキュメントは前回リリース以降のバグ修正を除くユーザーに影響のある機能の変更のリストです。

...eadable, IO#wait_writable, IO#read, IO#write and other related methods (e.g. IO#puts, IO#gets) may invoke the scheduler hook `#io_wait(io, events, timeout)` in a non-blocking execution context. 16786
* Kernel
* Kernel#clone when called with the `freeze: false` keyword will call `#initialize_cl...
...for `__LINE__` in the evaluated code. 4352
* Kernel#lambda now warns if called without a literal block. 15973
* Kernel.sleep invokes the scheduler hook `#kernel_sleep(...)` in a non-blocking execution context. 16786
* Module
* Module#include and Module#prepend now affect classes and mo...
...dependency and performance reasons.
* Set#join is added as a shorthand for `.to_a.join`.
* Set#<=> is added.
* Socket
* Add :connect_timeout to TCPSocket.new 17187
* Net::HTTP
* Net::HTTP#verify_hostname= and Net::HTTP#verify_hostname have been added to skip hostname verification...

Net::Telnet (18.0)

このクラスは telnet のクライアント機能を提供します。

..."Timeout" => 10)

# ログインし、プロンプトが出るまで待ち合わせる
telnet.login("your name", "your password") {|c| print c}

# ls コマンドを実行し、実行後、プロンプトが出るまで待ち合わせる
telnet.cmd("ls") {|c| print c}

# sleep...
...5 秒
telnet.cmd("sleep 5 && echo foobar &") {|c| print c}

STDOUT.flush # <- これがないとここまで処理が来てることがわかりにくい

# 前のコマンドの出力を待ち合わせる
telnet.waitfor(/foobar\Z/) {|c| print c}

# ログインセッションの終...