C
C
CleanyBoom2021-02-21 10:24:12
Python
CleanyBoom, 2021-02-21 10:24:12

Ignoring python vk api timeout error?

If a python bot runs long enough, it is thrown out with a vk-api error like

requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='im.vk.com', port=443): Read timed out. (read timeout=35)

Complete error
File "Textv2.py", line 117, in
for event in longpoll.listen():
File "/home/h4x4d/.local/lib/python3.8/site-packages/vk_api/longpoll.py", line 621, in listen
for event in self.check():
File "/home/h4x4d/.local/lib/python3.8/site-packages/vk_api/longpoll.py", line 557, in check
response = self.session.get(
File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 546, in get
return self.request('GET', url, **kwargs)
File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 533, in request
resp = self.send(prep, **send_kwargs)
File "/usr/lib/python3.8/site-packages/requests/sessions.py", line 646, in send
r = adapter.send(request, **kwargs)
File "/usr/lib/python3.8/site-packages/requests/adapters.py", line 529, in send
raise ReadTimeout(e, request=request)
requests.exceptions.ReadTimeout: HTTPSConnectionPool(host='im.vk.com', port=443): Read timed out. (read timeout=35)

Is it possible to somehow ignore it and continue execution, at least through a loop? I don't like that the bot crashes every 6 hours because of this. Thanks in advance!

PS I tried to constantly send him messages in order to "update the timeout", it does not help, he still fell

Answer the question

In order to leave comments, you need to log in

1 answer(s)
P
Puma Thailand, 2021-02-21
​​@CleanyBoom

Just hang an exception there and catch it with ketch

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question