Code Monkey home page Code Monkey logo

Comments (9)

rpdrewes avatar rpdrewes commented on August 24, 2024

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.

rpdrewes avatar rpdrewes commented on August 24, 2024

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.

rpdrewes avatar rpdrewes commented on August 24, 2024

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.

rpdrewes avatar rpdrewes commented on August 24, 2024

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.

rpdrewes avatar rpdrewes commented on August 24, 2024

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.

brandyn avatar brandyn commented on August 24, 2024

I believe this is a duplcate of #22

I have submitted a fix #25

from pyflac.

Related Issues (9)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.