-
Notifications
You must be signed in to change notification settings - Fork 5.9k
Description
Steps to reproduce
-
Use the echobot2 example code with a few changes list below.
-
In main function create a DictPersistence object with store_chat_data set to False.
-
Create the Updater object with persistence set to the object created in the second step.
-
Send SIGKILL to the process in which the example code is launched.
Expected behaviour
The code should normally terminate.
Actual behaviour
The code terminates with the following error:
File ".../echobot2.py", line 81, in main
updater.idle()
File ".../.venv/lib/python3.7/site-packages/telegram/ext/updater.py", line 529, in idle
sleep(1)
File ".../.venv/lib/python3.7/site-packages/telegram/ext/updater.py", line 504, in signal_handler
self.dispatcher.update_persistence()
File ".../.venv/lib/python3.7/site-packages/telegram/ext/dispatcher.py", line 437, in update_persistence
self.persistence.update_chat_data(chat_id, self.chat_data[chat_id])
File ".../.venv/lib/python3.7/site-packages/telegram/ext/dictpersistence.py", line 193, in update_chat_data
if self._chat_data.get(chat_id) == data:
AttributeError: 'NoneType' object has no attribute 'get'
Tracing back the error, it seems that when receiving the SIGKILL signal, the dispatcher is force updating the persistence object's chat data attribute without checking its store_chat_data attribute, see the following code from telegram.ext.dispatcher.py:
def update_persistence(self):
"""Update :attr:user_data and :attr:chat_data in :attr:persistence.
"""
if self.persistence:
for chat_id in self.chat_data:
self.persistence.update_chat_data(chat_id, self.chat_data[chat_id])
for user_id in self.user_data:
self.persistence.update_user_data(user_id, self.user_data[user_id])
Configuration
Operating System:
Manjaro 18.0.4 Illyria
Version of Python, python-telegram-bot & dependencies:
python-telegram-bot 12.0.0b1
certifi 2019.06.16
future 0.17.1
Python 3.7.3 (default, Jun 24 2019, 04:54:02) [GCC 9.1.0]