docs: def waitforthreads(threads, timeout=None):
      """Waits for one or more *Thread* to exit or until *timeout* expires.
  
      .. note::
  
         Expired *Threads* are not joined by *waitforthreads*.
  
      *threads* is a list containing one or more *threading.Thread* objects.
      If *timeout* is not None the function will block
      for the specified amount of seconds.
  
      The function returns a list containing the ready *Threads*.
  
      """
      old_function = None
      lock = threading.Condition(threading.Lock())
  
      def new_function(*args):
          old_function(*args)
          with lock:
              lock.notify_all()
  
      old_function = prepare_threads(new_function)
      try:
          wait_threads(threads, lock, timeout)
      finally:
          reset_threads(old_function)
  
      return filter(lambda t: not t.is_alive(), threads)