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

Fix sf_open error checking when used concurrently #279

Merged
merged 4 commits into from Oct 5, 2020

Conversation

jonashaag
Copy link
Contributor

@jonashaag jonashaag commented Sep 19, 2020

libsndfile error reporting is not thread safe, see libsndfile/libsndfile#279 libsndfile/libsndfile#610.

The patch does not attempt to fix that, but it changes the way errors are checked for in order to fix one specific race condition:

If opening a file not understood by libsndfile with sf.SoundFile, and then attempting to .read() from it, sometimes opening the file with sf.SoundFile does not report an error (due to the libsndfile race condition), and then the .read() fails. (As a consequence, librosa will not attempt to open the file using audioread, making librosa.load fail.)

@mgeier
Copy link
Contributor

mgeier commented Sep 26, 2020

Thanks for the PR.

The behavior of libsndfile is unfortunate, but I think this PR is a good work-around.

It would probably be helpful for future readers of the code to include the above-mentioned libsndfile issue links as comments in the source code?

tests/test_pysoundfile.py Outdated Show resolved Hide resolved
@jonashaag
Copy link
Contributor Author

So, we made some progress in libsndfile#610 but I think we should merge this anyway as it is "more correct" this way.

@jonashaag
Copy link
Contributor Author

Oh wow, Python 2.6 still supported... will have to adapt that test

@jonashaag
Copy link
Contributor Author

Btw, why aren't Travis results shown here?

Copy link
Contributor

@mgeier mgeier left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Thanks for the updates!

@mgeier
Copy link
Contributor

mgeier commented Sep 29, 2020

Btw, why aren't Travis results shown here?

Good question, I don't know, but I've also seen the effect on several of my projects.
For me, this was one more reason to switch from Travis-CI to Github Actions.

In case someone wants to see them, there are the Travis-CI logs: https://travis-ci.org/github/bastibe/SoundFile/pull_requests

@jonashaag
Copy link
Contributor Author

Anything preventing this from being merged?

@bastibe bastibe merged commit 0f84929 into bastibe:master Oct 5, 2020
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 this pull request may close these issues.

None yet

3 participants