def shutdown(self, wait=True):
    """
    Shut down the pool. If *wait* is True, it will wait until all futures
    are completed. Alternatively, you can use the #wait() method to wait
    with timeout supported.
    """

    with self._lock:
      self._shutdown = True
      self._lock.notify_all()
    if wait:
      self.wait()