code: def run(self):
          
          self.running = True
  
          def chunks_producer():
              while self.running:
                  self.chunks.put(self.next_chunks())
  
          t = Thread(target=chunks_producer)
          t.start()
  
          with self.BackendStream(samplerate=self.sr, channels=1) as stream:
              while self.running:
                  try:
                      stream.write(self.chunks.get(timeout=self.timeout))  # timeout so stream.write() thread can exit
                  except Empty:
                      self.running = False
docs: Play loop, i.e. send all sound chunk by chunk to the soundcard.