Answer the question
In order to leave comments, you need to log in
How to fix asyncio.exceptions.TimeoutError error?
Hello, I recently started to study the aiovk asynchronous library for writing a bot and immediately encountered a strange error. After reading the aiovk documentation, I wrote a small code that works properly until a certain point, namely until 2 am, for some reason at this time (I checked it for several days) the program crashes with an error.
Traceback:
Traceback (most recent call last):
File "D:/OTHERS/bot/test.py", line 27, in <module>
loop.run_until_complete(main())
File "C:\Program Files\bin\lib\asyncio\base_events.py", line 616, in run_until_complete
return future.result()
File "D:/OTHERS/bot/test.py", line 15, in main
data = await longpoll.wait()
File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\aiovk\longpoll.py", line 62, in wait
code, response = await self.api._session.driver.get_text(
File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\aiovk\drivers.py", line 61, in get_text
async with self.session.get(url, params=params, timeout=timeout or self.timeout) as response:
File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\aiohttp\client.py", line 1012, in __aenter__
self._resp = await self._coro
File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\aiohttp\client.py", line 504, in _request
await resp.start(conn)
File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\aiohttp\client_reqrep.py", line 860, in start
self._continue = None
File "C:\Users\adm\AppData\Roaming\Python\Python38\site-packages\aiohttp\helpers.py", line 596, in __exit__
raise asyncio.TimeoutError from None
asyncio.exceptions.TimeoutError
Process finished with exit code 1
async def main():
async with aiovk.TokenSession(access_token=TOKEN()) as session:
api = API(session)
longpoll = BotsLongPoll(session, mode=8, group_id=VK_GROUP_ID())
while True:
data = await longpoll.wait()
updates = data['updates']
for event in updates:
if event['type'] == 'message_new':
if event['object']['message']['text'].lower() == 'qqq':
await api("messages.send",
peer_id=event['object']['message']['peer_id'],
random_id=0,
message="q")
loop = asyncio.get_event_loop()
loop.run_until_complete(main())
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question