Wait for the future to complete. If *timeout* is specified, it must be a
    floating point number representing the maximum number of seconds to wait.

    :param timeout: The maximum number of seconds to wait for the future
      to complete.
    :param do_raise: Raise :class:`Timeout` when a timeout occurred.
    :raise Timeout: If a timeout occurred and *do_raise* was True.
    :return: :const:`True` if the future completed, :const:`False` if a
      timeout occurred and *do_raise* was set to False.

def wait(self, timeout=None, do_raise=False):
    """
    Wait for the future to complete. If *timeout* is specified, it must be a
    floating point number representing the maximum number of seconds to wait.

    :param timeout: The maximum number of seconds to wait for the future
      to complete.
    :param do_raise: Raise :class:`Timeout` when a timeout occurred.
    :raise Timeout: If a timeout occurred and *do_raise* was True.
    :return: :const:`True` if the future completed, :const:`False` if a
      timeout occurred and *do_raise* was set to False.
    """

    if timeout is not None:
      timeout = float(timeout)
      start = time.clock()

    with self._lock:
      while not self._completed and not self._cancelled:
        if timeout is not None:
          time_left = timeout - (time.clock() - start)
        else:
          time_left = None
        if time_left is not None and time_left <= 0.0:
          if do_raise:
            raise self.Timeout()
          else:
            return False
        self._lock.wait(time_left)
    return True