Skip to content
This repository has been archived by the owner on May 29, 2020. It is now read-only.

May underestimate requests (unreliable use of SCAN) #11

Open
asmello opened this issue May 28, 2019 · 0 comments
Open

May underestimate requests (unreliable use of SCAN) #11

asmello opened this issue May 28, 2019 · 0 comments

Comments

@asmello
Copy link

asmello commented May 28, 2019

In respectful_requester.py#L189, the pattern len(redis.scan()) is used.

According to the redis-py library documentation, scan() does no iteration itself, you are expected to use the returned cursor to fetch the remaining results manually. Line 189 seems to assume that passing a high enough count argument will ensure all results are returned, but according to the Redis documentation that is not the case.

The consequence is that _requests_in_timespan() might underestimate the number of requests in the timespan, making rate control unreliable.

A simple fix is to replace the scan() call with scan_iter(), which does ensure that the full result set is returned.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

No branches or pull requests

1 participant