Skip to content

Commit

Permalink
The Timeout::Error example no longer works consistently
Browse files Browse the repository at this point in the history
* This PR from the timeout gem (ruby/timeout#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: ruby/timeout#41
  • Loading branch information
jpcamara committed Aug 29, 2024
1 parent 8f700db commit ffe1ab4
Showing 1 changed file with 0 additions and 24 deletions.
24 changes: 0 additions & 24 deletions thread.c
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down

0 comments on commit ffe1ab4

Please sign in to comment.