Skip to content

Commit

Permalink
Only run timeout_after hook on fiber scheduler if scheduler exists
Browse files Browse the repository at this point in the history
  • Loading branch information
jeremyevans committed May 3, 2021
1 parent aecdaa2 commit 4893cde
Showing 1 changed file with 1 addition and 1 deletion.
2 changes: 1 addition & 1 deletion lib/timeout.rb
Original file line number Diff line number Diff line change
Expand Up @@ -85,7 +85,7 @@ def timeout(sec, klass = nil, message = nil, &block) #:yield: +sec+

message ||= "execution expired".freeze

if (scheduler = Fiber.current_scheduler)&.respond_to?(:timeout_after)
if Fiber.respond_to?(:current_scheduler) && (scheduler = Fiber.current_scheduler)&.respond_to?(:timeout_after)
return scheduler.timeout_after(sec, klass || Error, message, &block)
end

Expand Down

0 comments on commit 4893cde

Please sign in to comment.