Add experimental support for async sessions (#4667)

There no plans for this to ever be non-experimental in v1.
This commit is contained in:
Humberto Gontijo
2025-07-28 12:03:31 -03:00
committed by GitHub
parent 45a546a675
commit d80898ecc5
7 changed files with 75 additions and 46 deletions

View File

@@ -80,7 +80,7 @@ class UserMethods:
exceptions.append(e)
results.append(None)
continue
self.session.process_entities(result)
await utils.maybe_async(self.session.process_entities(result))
exceptions.append(None)
results.append(result)
request_index += 1
@@ -90,7 +90,7 @@ class UserMethods:
return results
else:
result = await future
self.session.process_entities(result)
await utils.maybe_async(self.session.process_entities(result))
return result
except (errors.ServerError, errors.RpcCallFailError,
errors.RpcMcgetFailError, errors.InterdcCallErrorError,
@@ -435,7 +435,8 @@ class UserMethods:
# No InputPeer, cached peer, or known string. Fetch from disk cache
try:
return self.session.get_input_entity(peer)
input_entity = await utils.maybe_async(self.session.get_input_entity(peer))
return input_entity
except ValueError:
pass
@@ -574,8 +575,8 @@ class UserMethods:
pass
try:
# Nobody with this username, maybe it's an exact name/title
return await self.get_entity(
self.session.get_input_entity(string))
input_entity = await utils.maybe_async(self.session.get_input_entity(string))
return await self.get_entity(input_entity)
except ValueError:
pass