Browse Source

Remove buckets from webhook ratelimit warnings

pull/8429/head
Rapptz 3 years ago
parent
commit
7d1cb08c6d
  1. 7
      discord/webhook/async_.py
  2. 7
      discord/webhook/sync.py

7
discord/webhook/async_.py

@ -189,9 +189,8 @@ class AsyncWebhookAdapter:
if remaining == '0' and response.status != 429: if remaining == '0' and response.status != 429:
delta = utils._parse_ratelimit_header(response) delta = utils._parse_ratelimit_header(response)
_log.debug( _log.debug(
'Webhook ID %s has exhausted its rate limit bucket (bucket: %s, retry: %s).', 'Webhook ID %s has exhausted its rate limit bucket (retry: %s).',
webhook_id, webhook_id,
bucket,
delta, delta,
) )
lock.delay_by(delta) lock.delay_by(delta)
@ -202,10 +201,10 @@ class AsyncWebhookAdapter:
if response.status == 429: if response.status == 429:
if not response.headers.get('Via'): if not response.headers.get('Via'):
raise HTTPException(response, data) raise HTTPException(response, data)
fmt = 'Webhook ID %s is rate limited. Retrying in %.2f seconds. Handled under the bucket %s' fmt = 'Webhook ID %s is rate limited. Retrying in %.2f seconds.'
retry_after: float = data['retry_after'] # type: ignore retry_after: float = data['retry_after'] # type: ignore
_log.warning(fmt, webhook_id, retry_after, bucket, stack_info=True) _log.warning(fmt, webhook_id, retry_after)
await asyncio.sleep(retry_after) await asyncio.sleep(retry_after)
continue continue

7
discord/webhook/sync.py

@ -188,9 +188,8 @@ class WebhookAdapter:
if remaining == '0' and response.status_code != 429: if remaining == '0' and response.status_code != 429:
delta = utils._parse_ratelimit_header(response) delta = utils._parse_ratelimit_header(response)
_log.debug( _log.debug(
'Webhook ID %s has exhausted its rate limit bucket (bucket: %s, retry: %s).', 'Webhook ID %s has exhausted its rate limit bucket (retry: %s).',
webhook_id, webhook_id,
bucket,
delta, delta,
) )
lock.delay_by(delta) lock.delay_by(delta)
@ -201,10 +200,10 @@ class WebhookAdapter:
if response.status_code == 429: if response.status_code == 429:
if not response.headers.get('Via'): if not response.headers.get('Via'):
raise HTTPException(response, data) raise HTTPException(response, data)
fmt = 'Webhook ID %s is rate limited. Retrying in %.2f seconds. Handled under the bucket %s' fmt = 'Webhook ID %s is rate limited. Retrying in %.2f seconds.'
retry_after: float = data['retry_after'] # type: ignore retry_after: float = data['retry_after'] # type: ignore
_log.warning(fmt, webhook_id, retry_after, stack_info=True) _log.warning(fmt, webhook_id, retry_after)
time.sleep(retry_after) time.sleep(retry_after)
continue continue

Loading…
Cancel
Save