mirror of
https://github.com/kokarare1212/librespot-python.git
synced 2026-04-25 16:45:50 +03:00
[GH-ISSUE #148] [BUG] AbsChunkedInputStream's wait_lock releases before chunk is ready #19
Labels
No labels
bug
dependencies
duplicate
enhancement
invalid
pull-request
question
No milestone
No project
No assignees
1 participant
Notifications
Due date
No due date set.
Dependencies
No dependencies set.
Reference
starred/librespot-python-kokarare1212#19
Loading…
Add table
Add a link
Reference in a new issue
No description provided.
Delete branch "%!s()"
Deleting a branch is permanent. Although the deleted branch may continue to exist for a short time before it actually gets removed, it CANNOT be undone in most cases. Continue?
Originally created by @yeralin on GitHub (Aug 18, 2022).
Original GitHub issue: https://github.com/kokarare1212/librespot-python/issues/148
Describe the bug
From time to time,
librespot-pythonlibrary would fail to play audio in the middle of the stream. After debugging the problem (hard to reproduce), I noticed thatAbsChunkedInputStream.read(__size: int = 0)method returns an empty buffer. After debugging it further, I tracked the problem down toAbsChunkedInputStream.wait_lockwhich is prematurely released under theAbsChunkedInputStream.check_availabilitymethod.So, I put a few debugging statements around the
wait()call:And received the following logs:
As you can see for chunk
#29,self.wait_lock.wait()returns before the chunk is downloaded; thus, the buffer returned empty.You can also verify that by checking
self.wait_for_chunkwhich is not-1. Although, it must be set to-1right beforeself.wait_lock.notify_all()calls.To Reproduce
As I mentioned reproducing this bug is difficult since it happens haphazardly.
Not entirely sure why this happens. I did some googling, but I haven't found anyone else encountering this problem before. I've been trying streaming songs >6 mins long, and in 1 out of 5 times this issue occurs.
Expected behavior
self.wait_lock.wait()call underAbsChunkedInputStream.check_availabilitymethod should return after the chunk is ready to be consumed.Client Information (please complete the following information):
git+https://github.com/kokarare1212/librespot-python(master)Additional context
One potential resolution that has worked for me was to change the call from
self.wait_lock.wait()toself.wait_lock.wait_for(lambda: self.available_chunks()[chunk]).Effectively, the result would be the same as we are blocking and waiting for the chunk to become available.
@kokarare1212 commented on GitHub (Aug 19, 2022):
Thank you for reporting the bug.
I have made the change.