mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-26 19:33:45 +03:00
Assume exported auths last forever
This implies that export senders will NOT be deleted from memory once all borrows are returned, thus their auth_key remains as well. When borrowing them if they existed they will be connect()ed if it's the first borrow. This probably fixes #901.
This commit is contained in:
parent
13437cc3f2
commit
5a9a00e7ae
|
@ -433,6 +433,9 @@ class TelegramBaseClient(abc.ABC):
|
||||||
if not sender:
|
if not sender:
|
||||||
sender = await self._create_exported_sender(dc_id)
|
sender = await self._create_exported_sender(dc_id)
|
||||||
sender.dc_id = dc_id
|
sender.dc_id = dc_id
|
||||||
|
elif not n:
|
||||||
|
dc = await self._get_dc(dc_id)
|
||||||
|
await sender.connect(dc.ip_address, dc.port)
|
||||||
|
|
||||||
self._borrowed_senders[dc_id] = (n + 1, sender)
|
self._borrowed_senders[dc_id] = (n + 1, sender)
|
||||||
|
|
||||||
|
@ -447,12 +450,10 @@ class TelegramBaseClient(abc.ABC):
|
||||||
dc_id = sender.dc_id
|
dc_id = sender.dc_id
|
||||||
n, _ = self._borrowed_senders[dc_id]
|
n, _ = self._borrowed_senders[dc_id]
|
||||||
n -= 1
|
n -= 1
|
||||||
if n > 0:
|
|
||||||
self._borrowed_senders[dc_id] = (n, sender)
|
self._borrowed_senders[dc_id] = (n, sender)
|
||||||
else:
|
if not n:
|
||||||
__log__.info('Disconnecting borrowed sender for DC %d', dc_id)
|
__log__.info('Disconnecting borrowed sender for DC %d', dc_id)
|
||||||
await sender.disconnect()
|
await sender.disconnect()
|
||||||
del self._borrowed_senders[dc_id]
|
|
||||||
|
|
||||||
async def _get_cdn_client(self, cdn_redirect):
|
async def _get_cdn_client(self, cdn_redirect):
|
||||||
"""Similar to ._borrow_exported_client, but for CDNs"""
|
"""Similar to ._borrow_exported_client, but for CDNs"""
|
||||||
|
|
Loading…
Reference in New Issue
Block a user