Mark certain SQLiteSession methods as async

Follow-up to d2de0f3aca.
This commit is contained in:
Lonami Exo 2022-05-12 11:08:18 +02:00
parent ecc036c7f4
commit f913ea6b75

View File

@ -201,7 +201,7 @@ class SQLiteSession(MemorySession):
)) ))
c.close() c.close()
def get_update_state(self, entity_id): async def get_update_state(self, entity_id):
row = self._execute('select pts, qts, date, seq from update_state ' row = self._execute('select pts, qts, date, seq from update_state '
'where id = ?', entity_id) 'where id = ?', entity_id)
if row: if row:
@ -210,12 +210,12 @@ class SQLiteSession(MemorySession):
date, tz=datetime.timezone.utc) date, tz=datetime.timezone.utc)
return types.updates.State(pts, qts, date, seq, unread_count=0) return types.updates.State(pts, qts, date, seq, unread_count=0)
def set_update_state(self, entity_id, state): async def set_update_state(self, entity_id, state):
self._execute('insert or replace into update_state values (?,?,?,?,?)', self._execute('insert or replace into update_state values (?,?,?,?,?)',
entity_id, state.pts, state.qts, entity_id, state.pts, state.qts,
state.date.timestamp(), state.seq) state.date.timestamp(), state.seq)
def save(self): async def save(self):
"""Saves the current session object as session_user_id.session""" """Saves the current session object as session_user_id.session"""
# This is a no-op if there are no changes to commit, so there's # This is a no-op if there are no changes to commit, so there's
# no need for us to keep track of an "unsaved changes" variable. # no need for us to keep track of an "unsaved changes" variable.
@ -240,7 +240,7 @@ class SQLiteSession(MemorySession):
finally: finally:
c.close() c.close()
def close(self): async def close(self):
"""Closes the connection unless we're working in-memory""" """Closes the connection unless we're working in-memory"""
if self.filename != ':memory:': if self.filename != ':memory:':
if self._conn is not None: if self._conn is not None:
@ -248,7 +248,7 @@ class SQLiteSession(MemorySession):
self._conn.close() self._conn.close()
self._conn = None self._conn = None
def delete(self): async def delete(self):
"""Deletes the current session file""" """Deletes the current session file"""
if self.filename == ':memory:': if self.filename == ':memory:':
return True return True
@ -268,7 +268,7 @@ class SQLiteSession(MemorySession):
# Entity processing # Entity processing
def process_entities(self, tlo): async def process_entities(self, tlo):
""" """
Processes all the found entities on the given TLObject, Processes all the found entities on the given TLObject,
unless .save_entities is False. unless .save_entities is False.