Пишу бота на aiogram 3.4.4. И в самом начале столкнулся с проблемой. Бо нормально запускается, работает, но при остановке бота в среде Pychram в консоле вылезает ряд сообщений. Может кто объяснить что вообще происходит и как поправить. Я новичок. В интернете не нашел ответа. Прошу не бить палками.
Код:
import logging
import asyncio
import sys
from aiogram import Bot, Dispatcher, types
from aiogram.filters.command import Command
from aiogram.enums.dice_emoji import DiceEmoji
BOT_TOKEN = '...'
bot=Bot(token=BOT_TOKEN)
dp = Dispatcher()
@dp.message(Command('start'))
async def start(message:types.Message):
await message.answer('Hello')
@dp.message(Command("dice"))
async def cmd_dice(message: types.Message):
await message.answer_dice(emoji="")
async def main():
await dp.start_polling(bot)
if __name__ == "__main__":
asyncio.run(main())
Ошибка в консоле:
Traceback (most recent call last):
File "D:\Prog\Python\pythonProject\Shop_bot\venv\main.py", line 41, in
asyncio.run (main())
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\runners.py", line 44, in run
return loop.run _until_complete(main)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 634, in run_until_complete
self.run _forever()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 321, in run_forever
super().run_forever()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 601, in run_forever
self._run_once()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 1869, in _run_once
event_list = self._ selector.select (timeout)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 439, in select
self._poll(timeout)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\windows_events.py", line 788, in _poll
status = _overlapped.GetQueuedCompletionStatus(self._iocp, ms)
KeyboardInterrupt
Exception ignored in:
Traceback (most recent call last):
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 116, in __del__
self.close()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\proactor_events.py", line 108, in close
self._ loop.call _soon(self._call_connection_lost, None)
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 751, in call_soon
self._check_closed()
File "C:\Users\Admin\AppData\Local\Programs\Python\Python39\lib\asyncio\base_events.py", line 515, in _check_closed
raise RuntimeError('Event loop is closed')
RuntimeError: Event loop is closed
Process finished with exit code -1073741510 (0xC000013A: interrupted by Ctrl+C)