Revert async sessions from 3dd8b7c (breaks sync properties)

Such as ChatGetter.input_chat and SenderGetter.input_sender
which rely on the fact that access to the session file will
be synchronous.
This commit is contained in:
Lonami Exo
2018-10-12 22:00:02 +02:00
parent e677a6bb05
commit cf6686ff42
6 changed files with 29 additions and 21 deletions

View File

@@ -137,7 +137,7 @@ class UpdateMethods(UserMethods):
This can also be used to forcibly fetch new updates if there are any.
"""
state = await self.session.get_update_state(0)
state = self.session.get_update_state(0)
if not state or not state.pts:
state = await self(functions.updates.GetStateRequest())
@@ -172,7 +172,7 @@ class UpdateMethods(UserMethods):
state.pts = d.pts
break
finally:
await self.session.set_update_state(0, state)
self.session.set_update_state(0, state)
self.session.catching_up = False
# endregion
@@ -180,7 +180,7 @@ class UpdateMethods(UserMethods):
# region Private methods
async def _handle_update(self, update):
await self.session.process_entities(update)
self.session.process_entities(update)
if isinstance(update, (types.Updates, types.UpdatesCombined)):
entities = {utils.get_peer_id(x): x for x in
itertools.chain(update.users, update.chats)}
@@ -236,7 +236,7 @@ class UpdateMethods(UserMethods):
# inserted because this is a rather expensive operation
# (default's sqlite3 takes ~0.1s to commit changes). Do
# it every minute instead. No-op if there's nothing new.
await self.session.save()
self.session.save()
# We need to send some content-related request at least hourly
# for Telegram to keep delivering updates, otherwise they will