code: def shutdown(self):
          
          if not self._shutdown:
              # send shutdown signal to the fetcher and join data queue first
              # Remark:   loop_fetcher need to be joined prior to the workers.
              #           otherwise, the the fetcher may fail at getting data
              self._data_queue.put((None, None))
              self._fetcher.join()
              # send shutdown signal to all worker processes
              for _ in range(self._num_workers):
                  self._key_queue.put((None, None))
              # force shut down any alive worker processes
              for w in self._workers:
                  if w.is_alive():
                      w.terminate()
              self._shutdown = True
docs: Shutdown internal workers by pushing terminate signals.