Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

ffdec hangs on wait #130

Closed
mightbecharles opened this issue Nov 15, 2022 · 2 comments · Fixed by #131
Closed

ffdec hangs on wait #130

mightbecharles opened this issue Nov 15, 2022 · 2 comments · Fixed by #131

Comments

@mightbecharles
Copy link
Contributor

I am using Librosa-0.9.2 on a project and encountered this issue with audioread-3.0.0.

Librosa calls available_backends(), which calls ffdec.available()

available() seems to hang indefinitely. But changing proc.wait() to proc.communicate() seems to fix the issue for my use case.

I saw in #113 that communicate() wasn't ideal, so maybe there's something else worth looking into?

@sampsyo
Copy link
Member

sampsyo commented Nov 15, 2022

Ah, this is a really good catch. While communicate() would be a problem for reading the actual output data from a "proper" invocation of ffmpeg, it actually seems like exactly the right thing for the ffdec.available() case.

In short, the problem with wait(), as currently written, is that the subprocess may fill up its output buffers—at which point it hangs, waiting for us (audioread) to consume something from those pipes. We're waiting for the ffmpeg process to exit, so that's a classic deadlock scenario.

I think we should use your change! Any chance you could submit a very small PR to this effect?

mightbecharles added a commit to mightbecharles/audioread that referenced this issue Nov 15, 2022
Fixes beetbox#130 by changing `wait()` to `communicate()` to avoid deadlock

See https://docs.python.org/3/library/subprocess.html#subprocess.Popen.wait for context.
@mightbecharles
Copy link
Contributor Author

@sampsyo Thanks, let me know if there are any problems!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants