Skip to content

Commit

Permalink
README: fix rate-limiting example
Browse files Browse the repository at this point in the history
  • Loading branch information
ValueRaider authored Feb 21, 2023
1 parent ca8c1c8 commit 7b95f55
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -206,11 +206,12 @@ Combine a `requests_cache` with rate-limiting to avoid triggering Yahoo's rate-l
from requests import Session
from requests_cache import CacheMixin, SQLiteCache
from requests_ratelimiter import LimiterMixin, MemoryQueueBucket
from pyrate_limiter import Duration, RequestRate, Limiter
class CachedLimiterSession(CacheMixin, LimiterMixin, Session):
""" """
pass

session = CachedLimiterSession(
per_second=0.9,
limiter=Limiter(RequestRate(2, Duration.SECOND*5), # max 2 requests per 5 seconds
bucket_class=MemoryQueueBucket,
backend=SQLiteCache("yfinance.cache"),
)
Expand Down

0 comments on commit 7b95f55

Please sign in to comment.