Skip to content
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions telegram/ext/basepersistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -557,6 +557,7 @@ def update_callback_data(self, data: CDCData) -> None:
"""
raise NotImplementedError

@abstractmethod
def flush(self) -> None:
"""Will be called by :class:`telegram.ext.Updater` upon receiving a stop signal. Gives the
persistence a chance to finish up saving or close a database connection gracefully.
Expand Down
7 changes: 7 additions & 0 deletions telegram/ext/dictpersistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -402,3 +402,10 @@ def refresh_bot_data(self, bot_data: Dict) -> None:
.. versionadded:: 13.6
.. seealso:: :meth:`telegram.ext.BasePersistence.refresh_bot_data`
"""

def flush(self) -> None:
"""Does nothing.

.. versionadded:: 14.0
.. seealso:: :meth:`telegram.ext.BasePersistence.flush`
"""
9 changes: 9 additions & 0 deletions tests/test_dispatcher.py
Original file line number Diff line number Diff line change
Expand Up @@ -632,6 +632,9 @@ def get_conversations(self, name):
def update_conversation(self, name, key, new_state):
pass

def flush(self) -> None:
pass

def start1(b, u):
pass

Expand Down Expand Up @@ -776,6 +779,9 @@ def refresh_user_data(self, user_id, user_data):
def refresh_chat_data(self, chat_id, chat_data):
pass

def flush(self) -> None:
pass

def callback(update, context):
pass

Expand Down Expand Up @@ -845,6 +851,9 @@ def refresh_user_data(self, user_id, user_data):
def refresh_chat_data(self, chat_id, chat_data):
pass

def flush(self) -> None:
pass

def callback(update, context):
pass

Expand Down
8 changes: 7 additions & 1 deletion tests/test_persistence.py
Original file line number Diff line number Diff line change
Expand Up @@ -98,6 +98,9 @@ def update_conversation(self, name, key, new_state):
def update_user_data(self, user_id, data):
raise NotImplementedError

def flush(self) -> None:
raise NotImplementedError


@pytest.fixture(scope="function")
def base_persistence():
Expand Down Expand Up @@ -148,6 +151,9 @@ def update_callback_data(self, data):
def update_conversation(self, name, key, new_state):
raise NotImplementedError

def flush(self) -> None:
raise NotImplementedError

return BotPersistence()


Expand Down Expand Up @@ -239,7 +245,7 @@ def test_abstract_methods(self, base_persistence):
with pytest.raises(
TypeError,
match=(
'get_bot_data, get_chat_data, get_conversations, '
'flush, get_bot_data, get_chat_data, get_conversations, '
'get_user_data, update_bot_data, update_chat_data, '
'update_conversation, update_user_data'
),
Expand Down