'Tell all the threads to terminate (by sending a sentinel value) and
wait for them to do so.'

def _wait_threads(self):

    for t in self._threads:
        self._to_fetch.put(None)
    for t in self._threads:
        t.join()
    self._threads = []
