るりまサーチ

最速Rubyリファレンスマニュアル検索!
12件ヒット [1-12件を表示] (0.015秒)
トップページ > クエリ:exception[x] > クエリ:timeout[x] > 種類:特異メソッド[x]

別のキーワード

  1. _builtin exception
  2. exception exception
  3. thread abort_on_exception=
  4. thread abort_on_exception
  5. bigdecimal exception_infinity

ライブラリ

クラス

検索結果

Thread.handle_interrupt(hash) { ... } -> object (37.0)

スレッドの割り込みのタイミングを引数で指定した内容に変更してブロックを 実行します。

...事ができます。

==== TimeoutError 対策

例:TimeoutError 発生のタイミングを制御する例

require 'timeout'
Thread.handle_interrupt(TimeoutError => :never) {
timeout
(10){
# TimeoutError => :never の指定により、ここでは TimeoutError が発生しない。...
...ead.handle_interrupt(TimeoutError => :on_blocking) {
# :on_blocking な処理は TimeoutError が発生し得る。
}
# TimeoutError => :never の指定により、ここでは TimeoutError が発生しない。
}
}

この例を ensure 節での TimeoutError 発生に応...
...きます。Timeout.#timeout はスレッドを使って実装さ
れているため、Thread.handle_interrupt による制御が有効です。

==== Stack control settings

It's possible to stack multiple levels of ::handle_interrupt blocks in order
to control more than one ExceptionClass and Timi...