Comments (9)
I experience this same super slow behavior when using this decoder in my project. The decoder.finish() takes about 3 seconds. I suspect this has something to do with coordination between the thread requesting the decoding and the thread that is doing the actual decoding, and not the actual decoding time required. I wish there were a way to do it all in the same thread!
If I replace the finish() with a sleep(.1) and then just look at the decoded data area, it is there in all my tests. It's like the sleep allows the decoding thread to do its work, which it can do quickly, and then we can proceed with the decoded data. But if you try to do a finish() then you are stuck waiting for multiple seconds.
If I don't have the sleep() and don't do a finish() and look immediately, then there is no decoded data in the output area.
from pyflac.
Looking at finish() in decoder.py, I bet it is this code that is causing the 3 second delay:
# --------------------------------------------------------------
# Instruct the decoder to finish up and wait until it is done
# --------------------------------------------------------------
self._done = True
super().finish()
self._thread.join(timeout=3)
if self._error:
raise DecoderProcessException(self._error)
There is a 3 second timeout coded in there for the thread join, and it takes 3 seconds every time. Very annoying.
from pyflac.
More information: the join() does appear to be timing out and the thread remains running! You can verify this with a check using decoder._thread.is_alive() .
So why is the join() timing out?
from pyflac.
The problem probably only appears when doing in-memory decoding (as opposed to outputting data to a file) because the blocking on I/O helps the threads share work (compute-bound threads with GIL can be problematic), but there is still a bug somewhere because the finish() should yield to the decoder thread, but the join() always takes the full 3 second timeout and the docoder thread still never exits!
from pyflac.
There was a bug in pyflac streaming logic (several actually) and there is a fix, which a colleague may be trying to get pulled into the repo at some point. The basic description of the problem above is correct: the thread join was never happening, the decoding thread never knew it was done.
from pyflac.
I believe this is a duplcate of #22
I have submitted a fix #25
from pyflac.
Related Issues (9)
- Tests don't properly check the raised exception
- Compress more than 2 channels HOT 3
- Illegal Instruction HOT 5
- Soundfile doesn't yet support Apple Silicon HOT 1
- DecoderProcessException and multiprocessing? HOT 1
- Add support for 24bit
- decoder.StreamingDecoder leaks active threads HOT 4
- only produce empty flac file HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from pyflac.