^ i think the solution that would work best is usi...
# ask-community
k
^ i think the solution that would work best is using a redis limiter in python. there seems to be a few of them. i dont see anything in prefect docs so i assume i need something custom.
Copy code
client = Redis() 
rate_limiter1 = RateLimit(client, "api1", max_calls=500, expire=10)
rate_limiter2 = RateLimit(client, "api2", max_calls=100, expire=10)

while True:
    if rate.check():
        api_call()
        rate.incr() # increment redis key
        break
    else:
        print("Rate limit exceeded. Sleeping for 10 seconds...")
        time.sleep(10) # sleep for 10 seconds
^ have NOT tested this. just a general idea. but something along these lines though. maybe this: https://github.com/evoluxbr/python-redis-rate-limit or this https://limits.readthedocs.io/en/latest/quickstart.html
👍 2
1