maximilionus / telemonitor

Telegram bot for monitoring your system
MIT License
3 stars 0 forks source link

On-shutdown event issue #1

Open maximilionus opened 4 years ago

maximilionus commented 4 years ago

Telemonitor is supposed to send notification message on bot shutdown. It works fine when you manually starting and stopping the bot, but when working as linux service it doesn't. Maybe it's just my "great" knowledge of .service configs, or maybe the problem is in something else.

Log file ```log [2020-06-29 03:27:35,339][aiogram][WARNING]: Updates were skipped successfully. [2020-06-29 03:27:35,689][asyncio][ERROR]: Task exception was never retrieved future: exception=InvalidQueryID('Query is too old and response timeout expired or query id is invalid')> Traceback (most recent call last): File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 339, in _process_polling_updates for responses in itertools.chain.from_iterable(await self.process_updates(updates, fast)): File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 194, in process_updates return await asyncio.gather(*tasks) File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/dispatcher/handler.py", line 117, in notify response = await handler_obj.handler(*args, **partial_data) File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/dispatcher/dispatcher.py", line 235, in process_update return await self.callback_query_handlers.notify(update.callback_query) File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/dispatcher/handler.py", line 117, in notify response = await handler_obj.handler(*args, **partial_data) File "/home/maximilionus/MAXIMILI/code/Telemonitor/Telemonitor/helpers.py", line 68, in __callback_sysinfo_press await bot.answer_callback_query(callback_query.id, 'Rebooting the system...') File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/bot/bot.py", line 1542, in answer_callback_query result = await self.request(api.Methods.ANSWER_CALLBACK_QUERY, payload) File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/bot/base.py", line 201, in request return await api.make_request(self.session, self.__token, method, data, files, File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/bot/api.py", line 104, in make_request return check_result(method, response.content_type, response.status, await response.text()) File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/bot/api.py", line 78, in check_result exceptions.BadRequest.detect(description) File "/root/.cache/pypoetry/virtualenvs/telemonitor-5n26Q-0w-py3.8/lib/python3.8/site-packages/aiogram/utils/exceptions.py", line 136, in detect raise err(cls.text or description) aiogram.utils.exceptions.InvalidQueryID: Query is too old and response timeout expired or query id is invalid ```
maximilionus commented 4 years ago

The issue is that executor.start_polling(on_shutdown=<callable>) event triggers only when stopping the python script by ^c (KeyboardInterrupt).