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

May underestimate requests (unreliable use of SCAN) #11

@asmello

Description

@asmello

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions