DEV Community

Ethan Zerad
Ethan Zerad

Posted on

The 41st Day of the 100 Days of Code Challenge

Hey everyone!

Today was another fun vacation day in my hometown, Paris!

I spent some time debugging my code some more to fix the concurrency issue and as I said yesterday, I learned that the problem was attempting to add new items to the audio stream during the transcription process which is impossible to do (impossible with RxPy's Subject).

So, the line that adds the audio chunk would become blocking and didn't finish executing until the transcription for the current buffer was done, effectively stopping the main thread's execution which is responsible for handling the server's requests and handling the new chunks. Right now, the socket ends up disconnecting every time because of what I believe to be the load on it after it suddenly handles the requests.

I created a new thread just for receiving the chunks so that it wouldn't block the main thread, but then it still blocked it.

After a conversation with ChatGPT, I learned that this function is probably holding the GIL and won't let other threads execute. I tested other threads doing simple operations as well and they stopped running. To bypass this limitation, I had to use multiprocessing, which creates an entirely new process.

I could also modify the way the stream is working somehow, but I prefer not to do it as this design for the stream and transcription process is working quite perfectly and I'd like to preserve it. However, I had a small problem with using multiprocess that I can't seem to figure out. It only occurs in a specific case and doesn't occur in the main file. Planning to debug it more tomorrow and that'll be it for this project as far as functionality goes. It will clearly work.

That's it for today,
Happy coding everyone!

Top comments (0)