telegram 机器人 出现错误:
File “/usr/local/lib/python3.4/dist-packages/telebot/apihelper.py”, line 54, in _make_request
timeout=(connect_timeout, read_timeout), proxies=proxy)
File “/usr/local/lib/python3.4/dist-packages/requests/sessions.py”, line 508, in request
resp = self.send(prep, **send_kwargs)
File “/usr/local/lib/python3.4/dist-packages/requests/sessions.py”, line 618, in send
r = adapter.send(request, **kwargs)
File “/usr/local/lib/python3.4/dist-packages/requests/adapters.py”, line 521, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host=’api.telegram.org’, port=443): Read timed out. (read timeout=30)
解决办法:
while True:
try:
bot.polling(none_stop=True)
# ConnectionError and ReadTimeout because of possible timout of the requests library
# TypeError for moviepy errors
# maybe there are others, therefore Exception
except Exception as e:
time.sleep(15)