Skip to content

Telegram "Too Many Requests" Error #1220

@Hagai

Description

@Hagai
  • I have marked all applicable categories:
    • exception-raising bug
    • visual output bug
  • I have visited the source website, and in particular
    read the known issues
  • I have searched through the issue tracker for duplicates
  • I have mentioned version numbers, operating system and
    environment, where applicable:
    ==
    import tqdm, sys
    import platform
    import requests
    print(requests.__version__, tqdm.__version__, sys.version, sys.platform)
    print(platform.platform())

2.22.0 4.50.2 3.7.7 (default, May 6 2020, 11:45:54) [MSC v.1916 64 bit (AMD64)] win32
Windows-10-10.0.19041-SP0

Issue can be reproduced by:

from tqdm.contrib.telegram import tqdm
for j in range(40):
  for i in tqdm(range(5000), token=TELEGRAM_TOKEN, chat_id=CHAT_ID):
      time.sleep(0.001) 

The error I got was KeyError: 'result' resulted from
tqdm\contrib\telegram.py in init(self, token, chat_id)
self.message_id = res.json()['result']['message_id']

The content of res.json() was:
{'ok': False, 'error_code': 429, 'description': 'Too Many Requests: retry after 3', 'parameters': {'retry_after': 3}}

Metadata

Metadata

Assignees

Type

No type

Projects

No projects

Milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions