Skip to content

Commit

Permalink
Update min version of requests-ratelimiter and update type hints for …
Browse files Browse the repository at this point in the history
…rate limit args (per_*)

Updates #535
  • Loading branch information
JWCook committed Jan 29, 2024
1 parent a7ec69b commit 7e282b9
Show file tree
Hide file tree
Showing 4 changed files with 14 additions and 9 deletions.
5 changes: 5 additions & 0 deletions docs/user_guide/advanced.md
Original file line number Diff line number Diff line change
Expand Up @@ -85,6 +85,11 @@ For example, to reduce the rate to 50 requests per minute:
>>> get_taxa(q='warbler', locale=1, session=session)
```

Float values also work, for example to slow it down to less than 1 request per second):
```python
>>> session = ClientSession(per_second=0.5)
```

### Distributed Application Rate Limiting
The default rate-limiting backend is thread-safe, and persistent across application restarts. If
you have a larger application running from multiple processes, you will need an additional locking
Expand Down
12 changes: 6 additions & 6 deletions poetry.lock

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 2 additions & 2 deletions pyinaturalist/session.py
Original file line number Diff line number Diff line change
Expand Up @@ -82,8 +82,8 @@ def __init__(
cache_control: bool = True,
expire_after: Optional[ExpirationTime] = None,
urls_expire_after: Optional[ExpirationPatterns] = None,
per_second: int = REQUESTS_PER_SECOND,
per_minute: int = REQUESTS_PER_MINUTE,
per_second: float = REQUESTS_PER_SECOND,
per_minute: float = REQUESTS_PER_MINUTE,
per_day: float = REQUESTS_PER_DAY,
burst: int = REQUEST_BURST_RATE,
bucket_class: Type[AbstractBucket] = SQLiteBucket,
Expand Down
2 changes: 1 addition & 1 deletion pyproject.toml
Original file line number Diff line number Diff line change
Expand Up @@ -48,7 +48,7 @@ python-dateutil = ">=2.0"
python-forge = ">=18.6"
requests = ">=2.25"
requests-cache = ">=1.1"
requests-ratelimiter = ">=0.3.2"
requests-ratelimiter = ">=0.5"
rich = ">=10.9"

# Optional dependencies
Expand Down

0 comments on commit 7e282b9

Please sign in to comment.