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

@@ -63,9 +63,12 @@ class _DirectDownloadIter(RequestIter):
config = await self.client(functions.help.GetConfigRequest())
for option in config.dc_options:
if option.ip_address == self.client.session.server_address:
self.client.session.set_dc(
option.id, option.ip_address, option.port)
self.client.session.save()
await utils.maybe_async(
self.client.session.set_dc(
option.id, option.ip_address, option.port
)
)
await utils.maybe_async(self.client.session.save())
break
# TODO Figure out why the session may have the wrong DC ID