Skip to content

Instantly share code, notes, and snippets.

@simonrobson
Last active December 16, 2015 06:39
Show Gist options
  • Save simonrobson/5393451 to your computer and use it in GitHub Desktop.
Save simonrobson/5393451 to your computer and use it in GitHub Desktop.
Celluloid::Timeout based on Celluloid::Future
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