Project

General

Profile

Actions

Bug #15886

closed

return in rescue block breaks Timeout.timeout

Added by moio (Silvio Moioli) almost 5 years ago. Updated almost 5 years ago.

Status:
Rejected
Assignee:
-
Target version:
-
ruby -v:
ruby 2.5.1p57 (2018-03-29 revision 63029) [x86_64-linux-gnu]
[ruby-core:92882]

Description

Passing Timeout.timeout a block with a rescue clause that contains a return statement prevents Timeout::Error to be raised as expected.

Reproducer:

require 'timeout'

begin
  Timeout.timeout(1) do
    begin
      sleep 10
    ensure
      puts "ensure block executed"

      ## commenting line below restores expected behaviour
      return true

    end
  end
rescue Timeout::Error => e
  puts "EXPECTED BEHAVIOUR: timeout error rescued"
end

Expected output:

ensure block executed
EXPECTED BEHAVIOR: timeout error rescued

Actual output:

ensure block executed

Looking in Redmine the following two issues appear related (but I lack the insight to tell for sure):

I apologize in advance if this issue is a duplicate.

Actions

Also available in: Atom PDF

Like0
Like0Like0Like0Like0Like0Like0Like0