Use finally in run_bulk_job and catch StopIteration#62
Merged
desilinguist merged 3 commits intopygridtools:masterfrom Mar 12, 2018
Merged
Use finally in run_bulk_job and catch StopIteration#62desilinguist merged 3 commits intopygridtools:masterfrom
finally in run_bulk_job and catch StopIteration#62desilinguist merged 3 commits intopygridtools:masterfrom
Conversation
While there is separate handling for `except` and `else` of a `try` block, they don't seem to be doing anything significantly different. So just use a `finally` statement instead and drop `except` and `else`.
As `run_bulk_job` can sometimes raise a `StopIteration` and this is deprecated behavior, catch and squash this exception. Thus avoiding the deprecated behavior. As this still breaks the loop and ends the generator, this has no real effect on how this generator behaves.
Contributor
Author
|
Failing because Travis CI switched to Ubuntu Trusty and the CI install was designed around Ubuntu Precise. PR ( #63 ) configures Travis CI to use Ubuntu Precise anyways, which fixes the issue. Will rebase after that is merged. |
Contributor
Author
|
@desilinguist, could you please take a look at these two PRs? |
Contributor
|
Sorry for the delay. I merged #63. |
…_finally_run_bulk_job'
Contributor
Author
|
No worries. Thanks for taking a look. Merged |
Contributor
|
Looks good to me 👍. |
2 similar comments
Contributor
Author
|
Thanks. Looks like it's good to go. |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Fixes #54
Previously this code was using
exceptandelseto do the same handling. Better to just usefinallyin this case, which is what we do here.Also squash a
StopIterationexception that is not otherwise caught. Not totally sure how it was getting raised in the first place, but catching it avoids aDeprecationWarningand has no real other effect for the code.cc @pitrou