Last active
December 16, 2015 06:39
-
-
Save simonrobson/5393451 to your computer and use it in GitHub Desktop.
Celluloid::Timeout based on Celluloid::Future
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module Celluloid | |
class Timeout | |
public | |
def self.timeout(sec, exception_class = TimeoutError, &block) | |
future = Celluloid::Future.new(&block) | |
begin | |
future.value(sec) | |
rescue ::Celluloid::TimeoutError => e | |
raise exception_class || e | |
end | |
end | |
end | |
end |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment