Provide RateLimit info #167
rogerallen
started this conversation in
Ideas
Replies: 3 comments 10 replies
|
Hi. Typically when you are rate-limited exception will be raised. The exception provides access to the XrpcError instance and response headers. In headers, you can find information about limits. I guess there is no way to receive headers without reaching the limit. |
0 replies
|
Seems like it would be best to proactively limit yourself if you are getting close to rate limits. Could/should I make this an Request For Enhancement (RFE)? |
2 replies
|
Hello. I prepared simple example of override method that gives you access to response headers (which contains rate limits). class RateLimitedClient(Client):
def __init__(self, *args, **kwargs) -> None:
super().__init__(*args, **kwargs)
self._limit = self._remaining = self._reset = None
def get_rate_limit(self):
return self._limit, self._remaining, self._reset
def _invoke(self, *args, **kwargs):
response = super()._invoke(*args, **kwargs)
self._limit = response.headers.get('ratelimit-limit')
self._remaining = response.headers.get('ratelimit-remaining')
self._reset = response.headers.get('ratelimit-reset')
return responseUsage: client = RateLimitedClient()
client.login(os.environ['USERNAME'], os.environ['PASSWORD'])
post = client.get_timeline()
print(client.get_rate_limit()) |
8 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment

Uh oh!
There was an error while loading. Please reload this page.
Hi there, I'm currently working on debugging why my bot hits rate limit issues and I don't know how to access this info via atproto.
I see logging.debug messages on certain calls will print out this info:
But I don't know how to query this
RateLimitinfo via the atproto library.All reactions