Allow finer control of API errors in client code (issue #43)#44
Open
eggpi wants to merge 5 commits intoalexz-enwp:masterfrom
Open
Allow finer control of API errors in client code (issue #43)#44eggpi wants to merge 5 commits intoalexz-enwp:masterfrom
eggpi wants to merge 5 commits intoalexz-enwp:masterfrom
Conversation
According to https://www.mediawiki.org/wiki/Manual:Maxlag_parameter, this may happen for caching layer errors.
Also remove some retry logic, since we now retry from query().
mzmcbride
reviewed
Jan 4, 2017
wikitools/api.py
Outdated
|
|
||
|
|
||
| retries - How many retries to allow for in case of errors (set to 0 for no | ||
| retries). If the number of attempts is exceeeded, an exception is raised: |
| except Exception, e: | ||
| print 'Attempt %d (of %d) raised exception %r' % (attempt, attempts, e) | ||
| if attempt == attempts: | ||
| raise |
Collaborator
There was a problem hiding this comment.
Should this be more explicit?
mzmcbride
reviewed
Jan 4, 2017
| error = content['error']['code'] | ||
| if error == "maxlag": | ||
| lagtime = int(re.search("(\d+) seconds", content['error']['info']).group(1)) | ||
| lagtime = 0.5 + float(re.search("([0-9.-]+) seconds", |
Collaborator
There was a problem hiding this comment.
Should this addition of "0.5" have an inline code comment? It seems non-obvious to me.
Collaborator
There was a problem hiding this comment.
Hmmm, never mind. This isn't really new logic.
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.
How about something like this for #43? This also includes a little bit of cleanup, and I think it's ready for a first look.
I've only tested manually so far (basically following the examples in the README with different retry parameters). I think I might be able to add some unit tests later, but let me know if there are any other testing you normally do.