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
Make the async version of the client easier to use #79
Conversation
|
||
responses = [( | ||
response.json() if response.ok else APIError(response) | ||
) for response in self.requests.map(reqs)] |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
The pool needs to have a (safe) size to prevent firing too many concurrent API requests.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Done in 920782d
It seems weird that |
Hm, I actually thought that it's more intuitive than the alternative where an async client sends requests synchronously upon An alternative could be to have |
# max_retries limit is reached | ||
retries = 0 | ||
while True and retries < max_retries: | ||
n_errors = sum([int(isinstance(response, APIError)) |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
ValidationError
inherits APIError
. We should make sure it doesn't get retried though.
Closing this PR as it seems we're all in consensus that such a specific async implementation within our library is not necessary. Will follow the path that PR #78 lays out instead. |
This is an alternative to #78 fixing some of the async client's flaws instead of removing it altogether.
Example usage:
I'm still conflicted whether such a deep integration of concurrency is good for this client library and its users or not. On the one hand, it makes concurrent requests easier to construct and send, and it handles API errors and retry logic properly (-ish). On the other hand, it makes the code more complex (and thus harder to read/understand), it forces a particular implementation of concurrency (green threads & gevent), and there are still some quirks with it (e.g. using the "debug" flag differs unintuitively between the sync and async client).
@closeio/engineering what do you think?
This PR introduces breaking changes and should be published along with a major version bump.