mirror of
https://github.com/HumanAIGC-Engineering/gradio-webrtc.git
synced 2026-02-05 18:09:23 +08:00
Improve Interruption Handling (#134)
* Clear websocket queue on interrupt * add code
This commit is contained in:
@@ -431,10 +431,14 @@ class AudioCallback(AudioStreamTrack):
|
||||
self.set_additional_outputs = set_additional_outputs
|
||||
|
||||
def clear_queue(self):
|
||||
if self.queue:
|
||||
while not self.queue.empty():
|
||||
self.queue.get_nowait()
|
||||
self._start = None
|
||||
logger.debug("clearing queue")
|
||||
logger.debug("queue size: %d", self.queue.qsize())
|
||||
i = 0
|
||||
while not self.queue.empty():
|
||||
self.queue.get_nowait()
|
||||
i += 1
|
||||
logger.debug("popped %d items from queue", i)
|
||||
self._start = None
|
||||
|
||||
def set_channel(self, channel: DataChannel):
|
||||
self.channel = channel
|
||||
|
||||
Reference in New Issue
Block a user