def timeout(seconds)
      thread = Thread.new  { Thread.current[:result] = yield }
      thread.join(seconds) ? (return thread[:result]) : (raise TimeoutError)
    ensure
      Thread.kill(thread) unless thread.nil?
    end
def timeout(seconds)
      thread = Thread.new  { Thread.current[:result] = yield }
      thread.join(seconds) ? (return thread[:result]) : (raise TimeoutError)
    ensure
      Thread.kill(thread) unless thread.nil?
    end
Wait the given number of seconds for the block operation to complete.
 Intended to be a simpler and more reliable replacement to the Ruby
 standard library `Timeout::timeout` method.

 @param [Integer] seconds
   Number of seconds to wait for the block to terminate. Any number may
   be used, including Floats to specify fractional seconds. A value of 0
   or nil will execute the block without any timeout.

 @return [Object]
   Result of the block if the block completed before the timeout,
   otherwise raises a TimeoutError exception.

 @raise [Hoodie::TimeoutError]
   When the block operation does not complete in the alloted time.

 @see Ruby Timeout::timeout