зеркало из https://github.com/github/ruby.git
The Timeout::Error example no longer works consistently
* This PR from the timeout gem (https://github.com/ruby/timeout/pull/30) made it so you have to handle_interrupt on Timeout::ExitException instead of Timeout::Error * Efficiency changes to the gem (one shared thread) mean you can't consistently handle timeout errors using handle_timeout: https://github.com/ruby/timeout/issues/41
This commit is contained in:
Родитель
19c1f0233e
Коммит
b5f1291015
24
thread.c
24
thread.c
|
@ -2215,30 +2215,6 @@ handle_interrupt_arg_check_i(VALUE key, VALUE val, VALUE args)
|
|||
* resource allocation code. Then, the ensure block is where we can safely
|
||||
* deallocate your resources.
|
||||
*
|
||||
* ==== Guarding from Timeout::Error
|
||||
*
|
||||
* In the next example, we will guard from the Timeout::Error exception. This
|
||||
* will help prevent from leaking resources when Timeout::Error exceptions occur
|
||||
* during normal ensure clause. For this example we use the help of the
|
||||
* standard library Timeout, from lib/timeout.rb
|
||||
*
|
||||
* require 'timeout'
|
||||
* Thread.handle_interrupt(Timeout::Error => :never) {
|
||||
* timeout(10){
|
||||
* # Timeout::Error doesn't occur here
|
||||
* Thread.handle_interrupt(Timeout::Error => :on_blocking) {
|
||||
* # possible to be killed by Timeout::Error
|
||||
* # while blocking operation
|
||||
* }
|
||||
* # Timeout::Error doesn't occur here
|
||||
* }
|
||||
* }
|
||||
*
|
||||
* In the first part of the +timeout+ block, we can rely on Timeout::Error being
|
||||
* ignored. Then in the <code>Timeout::Error => :on_blocking</code> block, any
|
||||
* operation that will block the calling thread is susceptible to a
|
||||
* Timeout::Error exception being raised.
|
||||
*
|
||||
* ==== Stack control settings
|
||||
*
|
||||
* It's possible to stack multiple levels of ::handle_interrupt blocks in order
|
||||
|
|
Загрузка…
Ссылка в новой задаче