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

Allow finer control of API errors in client code (issue #43) #44

Open
wants to merge 5 commits into
base: master
Choose a base branch
from

Conversation

eggpi
Copy link

@eggpi eggpi commented Jan 3, 2017

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.



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:
Copy link
Collaborator

Choose a reason for hiding this comment

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

"exceeeded"

Copy link
Author

Choose a reason for hiding this comment

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

Thanks!

except Exception, e:
print 'Attempt %d (of %d) raised exception %r' % (attempt, attempts, e)
if attempt == attempts:
raise
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this be more explicit?

Copy link
Author

Choose a reason for hiding this comment

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

Hmm, what do you suggest?

@@ -317,7 +317,8 @@ def __exceptionFromAPIError(self, data, content):
raise APIError(data)
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",
Copy link
Collaborator

Choose a reason for hiding this comment

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

Should this addition of "0.5" have an inline code comment? It seems non-obvious to me.

Copy link
Collaborator

Choose a reason for hiding this comment

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

Hmmm, never mind. This isn't really new logic.

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.

2 participants