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

rest request retry upon failure #63

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

Conversation

barrysteyn
Copy link
Contributor

When a rest request fails, it should be retried again before giving up. This is best practice (and in fact, I implemented this very feature for Microsoft OneNote).

The code below needs to be unit tested to ensure no regressions. However, we have not agreed upon the framework, so I will do it once it is up.

Lastly, I needed to implement this feature because crypto-compare has been giving lots of 503 responses lately. 503 response is temp unavailable, and one should try again in that case.

@@ -21,6 +24,20 @@
class Requester:
"Basic Requester using requests and blocking calls"

retries = attr.ib(default=attr.Factory(
config_item_getter('REQUESTER', 'retries')),
Copy link
Owner

Choose a reason for hiding this comment

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

Nice! For the other classes I tried to have the ini file section have the same title as the class name (i.e. the same case). Not sure if that runs foul of INI file conventions of being all upper case. The aim was that with the ConfigMixin it would automatically find the correct section and be open for extension by subclasses. It was a bit tricky and I see that for the api keys in Luno and BraveNewCoin we didn't follow that. However it does seem to work for assets and currencies (e.g. for Luno) but I think you have to define a custom validator.

Copy link
Contributor Author

@barrysteyn barrysteyn Dec 4, 2017

Choose a reason for hiding this comment

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

Donald Knuth's famous quote (and what I tell my team often) may apply here: Premature optimization is the root of all evil. My take is that we may be overthinking things a bit here. Lets just try make things simple for now. In that regard, I propose making things all capitals (like the ConfigSetter examples online) and have the spelling identical to the class name.

Also, those custom validators look like code bloat to me...

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