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

Improved error handling #16

Closed
wants to merge 5 commits into from
Closed

Improved error handling #16

wants to merge 5 commits into from

Conversation

Rafagd
Copy link
Contributor

@Rafagd Rafagd commented Oct 14, 2020

  • pypesq now has an on_error parameter that decides the behaviour of the function on error
  • cypesq will now call cypesq_retvals and raise an exception if the returned value is negative
  • cypesq_retvals will not crash-and-burn if no utterances are detected in the buffer
  • pesq_measure will now return early and override the Error_Flag with its own values instead of exposing internal Error_Flags
  • pow_of exit(1)'s were changed to asserts
  • Adding vIM buffer files to .gitignore

- cypesq will now call cypesq_retvals and raise an exception if the returned value is negative
- cypesq_retvals will not crash-and-burn if no utterances are detected in the buffer
- pesq_measure will now return early and override the Error_Flag with its own values instead of exposing internal Error_Flags
- pow_of exit(1)'s were changed to asserts
- Adding vIM buffer files to .gitignore
@ludlows
Copy link
Owner

ludlows commented Oct 15, 2020

thanks for your work.

could you add correspoding testing functions for the new error throwing feature inside the folder tests .

@jonashaag
Copy link

Does the library support multi threaded usage? If so, I think it would be better to at least use thread locals for error reporting so that error reporting is thread safe as well.

@boeddeker
Copy link
Contributor

I once tried to release the GIL in PESQ and it turned out, that PESQ uses some global statements (It either broke or returned wrong values, I don't remember).
In my code I currently always assume that PESQ is not thread safe.

Maybe that would be a point for the future: Release the GIL and make the code thread safe.

pesq/cypesq.pyx Outdated Show resolved Hide resolved
@boeddeker
Copy link
Contributor

Is there a reason, why you changed so many code lines?
It looks like many parts of the old code did the same.
Since PESQ has an official source code, I think it would be nice to be as close as possible to this.

@Rafagd
Copy link
Contributor Author

Rafagd commented Oct 15, 2020

Is there a reason, why you changed so many code lines?
It looks like many parts of the old code did the same.
Since PESQ has an official source code, I think it would be nice to be as close as possible to this.

It was the only way to reliably return the errors using the Error_Flag that was already present instead of having 2 different error returning mechanisms like in the other PR. Previously there was no way I could know what values would be returned, as each function inside the pesq_measure does a different thing with the Error_Flag and pesq_measure was just returning the same value to the outside world.

That said, I think I'll double check for leaks.

Ps.: Most of the lines are reindentation as well.

@boeddeker
Copy link
Contributor

Then I probably don't see what you changed.
Github shows too much deltas.
I see that you removed many

if ((*Error_Flag) == 0)
{

and this changed the indent, so the github diff is difficult to read.

@Rafagd
Copy link
Contributor Author

Rafagd commented Oct 15, 2020

So, the way the function was written, it checks for the Error_Flag then it calls the next function that may change the flag. To make sure I'm always talking about the last Error_Flag, I do the thing first, then I check the flag and return early. Otherwise I would need to double check the flag multiple times. I may need to add a goto there to do some clean-up on failure.

@jonashaag
Copy link

and this changed the indent, so the github diff is difficult to read.

There is an option to hide all white space changes.

@Rafagd
Copy link
Contributor Author

Rafagd commented Oct 15, 2020

There is an option to hide all white space changes.

TIL. OMG, that is so much better to read!

tests/test_pesq.py Outdated Show resolved Hide resolved
There is no need for it.
@ludlows
Copy link
Owner

ludlows commented Dec 16, 2020

hi @Rafagd, thanks for your contribution.
would you like to send this PR to the dev branch established by me 3 days ago?

@Rafagd
Copy link
Contributor Author

Rafagd commented Dec 26, 2020

Sorry for the delay, just did it now.

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

4 participants