-
Notifications
You must be signed in to change notification settings - Fork 108
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
Hanging in close() #9
Comments
Thanks for the detailed & complete bug report. Alas, I still can't seem to reproduce this on my machine (also ffmpeg 2.1, but on a Linux box; my Mac has a dead battery today 😲). I can think of two possibilities for what could be going on here:
In either case, maybe seeing ffmpeg's output will help clarify things. Can you try putting a print statement into your copy of audioread in the ReaderThread loop? Specifically, |
[ Original reply, please see below. https://gist.github.com/dracos/7334094 has two files, "works" and "hangs" - I cut streams of binary data and replaced with Ooh, if I get rid of the function and have this script: import audioread.ffdec
import os
import sys
root = 'speeches/fixtures/expected_outputs/mp3'
for mp3 in os.listdir(root):
mp3 = os.path.join(root, mp3)
print >>sys.stderr, mp3
f = audioread.ffdec.FFmpegAudioFile(mp3)
print >>sys.stderr, round(f.duration) Then I can't get that to hang ever, and STDOUT prints a lot more data than with the "in a function" version. Hang on, I'll
Whilst if I switch it back to using the function:
No idea why it being in the function makes a difference, but hope that's helpful |
Very interesting. I think the reason there's a difference between the two is that, with the function wrapper, Based on this output, here's my best guess at what's going on. (Perplexingly, I can't reproduce this on my Mac either, so we're flying somewhat blind.)
So we're deadlocked: the Python program is waiting for ffmpeg to write to stderr and the ffmpeg process is waiting for the Python program to empty its stdout buffer. To verify whether this is happening, can you drop a few print statements into the FFmpegAudioFile constructor and other methods? Before and after the |
It's a global variable, but (e.g. if I put the print in Okay, print statements before/after
Using a function (the fourth time I ran the script, first three runs did not hang):
Ctrl-C as before lets it carry on successfully and complete. I note the code reference is always the same when using a function; dunno if that's of any relevance. |
So much for that theory! Looks like Can we determine which line in |
Yes, it's hanging at the |
Very mysterious. My next step, if I could reproduce this on my machine, would be to attach to the hung ffmpeg process with gdb and get a backtrace to see exactly where it's stuck. (It's likely in a system call, so hopefully debug symbols won't be necessary.) But I realize that's a lot to ask you to do—if you're comfortable with gdb basics, then please go ahead, but otherwise, maybe we can work harder to reproduce the problem on a box I have access to. |
Interesting diversion into getting gdb to run on Mavericks :) I don't know gdb very well, so all I can give you is:
Which I'm guessing isn't that helpful. If I type Ran it a few more (hanging) times, generally get the same, but I have also seen longer backtraces, such as:
|
Argh; I was hoping we'd at least get to see symbols for the libc calls. No such luck. 😢 One more thing to try: while ffmpeg is hanging, run I wish there were a way for me to reproduce this so I could observe what's going on. If we need to resort to it, would it be possible for you to let me ssh into your machine to reproduce the problem? I realize that's a big security problem, so I understand if it's not possible, but I promise not to trash your machine. |
Afraid all it gives is:
And nothing further. |
Ah, too bad! All my tools are failing me. Yes, a Skype screen-share might be just the thing. (You can watch me fumble around with CLI tools.) I'm on Pacific time (US). Send me an email (on my profile page) and maybe we can find a time that works? |
Mac OS X 10.9, ffmpeg 2.1 from MacPorts, audioread 1.0.1 from pypi.
If I have the following small file (with the directory of MP3s being the one from this repository - https://github.com/mysociety/sayit ):
Then sometimes it will run fine, but frequently it will hang on one of the files. As far as I have been able to work out, it is hanging on the
wait()
insideclose()
, but I'm not sure what I should do in order to debug it further. Running ffmpeg manually, I can't see any problems. I can Ctrl-C, in which case I get a message:Exception KeyboardInterrupt: KeyboardInterrupt() in <bound method FFmpegAudioFile.__del__ of <audioread.ffdec.FFmpegAudioFile object at 0x1087cff90>> ignored
and the file continues running without issue (printing the duration, in this case), but leaves an ffmpeg process lying about that I have to manuallykill -9
.Hope that's useful, do let me know if you'd like any further information to help debug or fix this.
The text was updated successfully, but these errors were encountered: