Skip to content

Commit 17dc987

Browse files
Fix buffered generator hang by ensuring None sentinel delivery (#2566)
1 parent a4ca978 commit 17dc987

File tree

1 file changed

+4
-2
lines changed

1 file changed

+4
-2
lines changed

music_assistant/helpers/buffered_generator.py

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -78,8 +78,10 @@ async def producer() -> None:
7878
if not generator_consumed:
7979
await close_async_generator(generator)
8080
# Signal end of stream by putting None
81-
with contextlib.suppress(asyncio.QueueFull):
82-
buffer.put_nowait(None)
81+
# We must wait for space in the queue if needed, otherwise the consumer may
82+
# hang waiting for data that will never come
83+
if not cancelled.is_set():
84+
await buffer.put(None)
8385

8486
# Start the producer task
8587
loop = asyncio.get_running_loop()

0 commit comments

Comments
 (0)