code: def stop(self, graceful=False):
          
          self.stop_flag.set()
          if graceful:
              self._logger.info('Shutting down gracefully...')
              try:
                  for _, worker_process in self.worker_threads:
                      worker_process.join()
              except KeyboardInterrupt:
                  self._logger.info('Received request to shut down now.')
              else:
                  self._logger.info('All workers have stopped.')
          else:
              self._logger.info('Shutting down')
docs: Set the stop-flag.
  
          If `graceful=True`, this method blocks until the workers to finish
          executing any tasks they might be currently working on.