Skip to content

Commit d56d025

Browse files
ioquatixhsbt
authored andcommitted
Update method name and add documentation.
1 parent 1ab3226 commit d56d025

File tree

1 file changed

+5
-2
lines changed

1 file changed

+5
-2
lines changed

lib/timeout.rb

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -73,6 +73,9 @@ def exception(*)
7373
# ensure to prevent the handling of the exception. For that reason, this
7474
# method cannot be relied on to enforce timeouts for untrusted blocks.
7575
#
76+
# If a scheduler is defined, it will be used to handle the timeout by invoking
77+
# Scheduler#timeout_after.
78+
#
7679
# Note that this is both a method of module Timeout, so you can <tt>include
7780
# Timeout</tt> into your classes so they have a #timeout method, as well as
7881
# a module method, so you can call it directly as Timeout.timeout().
@@ -81,8 +84,8 @@ def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+
8184

8285
message ||= "execution expired".freeze
8386

84-
if (scheduler = Fiber.scheduler)&.respond_to?(:timeout_raise)
85-
return scheduler.timeout_raise(sec, klass || Error, message, &block)
87+
if (scheduler = Fiber.scheduler)&.respond_to?(:timeout_after)
88+
return scheduler.timeout_after(sec, klass || Error, message, &block)
8689
end
8790

8891
from = "from #{caller_locations(1, 1)[0]}" if $DEBUG

0 commit comments

Comments
 (0)