parameters: (self, timeout=None)
docstring: Stops running threads and wait for them to exit, if necessary.
  
      Should be called by the same thread which called `start()`.
  
      Arguments:
          timeout: maximum time to wait on `thread.join()`.
docstring_summary: Stops running threads and wait for them to exit, if necessary.
docstring_tokens: Stops running threads and wait for them to exit if necessary .
function: def stop(self, timeout=None):
      """Stops running threads and wait for them to exit, if necessary.
  
      Should be called by the same thread which called `start()`.
  
      Arguments:
          timeout: maximum time to wait on `thread.join()`.
      """
      if self.is_running():
        self._stop_event.set()
  
      for thread in self._threads:
        if thread.is_alive():
          if self._use_multiprocessing:
            thread.terminate()
          else:
            thread.join(timeout)
  
      if self._use_multiprocessing:
        if self.queue is not None:
          self.queue.close()
  
      self._threads = []
      self._stop_event = None
      self.queue = None
function_tokens: def stop ( self , timeout = None ) : if self . is_running ( ) : self . _stop_event . set ( ) for thread in self . _threads : if thread . is_alive ( ) : if self . _use_multiprocessing : thread . terminate ( ) else : thread . join ( timeout ) if self . _use_multiprocessing : if self . queue is not None : self . queue . close ( ) self . _threads = [ ] self . _stop_event = None self . queue = None