mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2025-08-10 18:59:33 +00:00
Clean-up client's __init__ and remove entity cache
Entity cache uses are removed. It was a source of ever-growing memory usage that has to be reworked. This affects everything that tried to obtain an input entity, input sender or input chat (such as the SenderGetter or calls to _get_entity_pair). Input entities need to be reworked in any case. Its removal also affects the automatic cache of any raw API request. Raise last error parameter is removed, and its behaviour made default. The connection type parameter has been removed, since users really have no need to change it. A few more attributes have been made private, since users should not mess with those.
This commit is contained in:
@@ -578,20 +578,16 @@ def get_input_group_call(call):
|
||||
_raise_cast_fail(call, 'InputGroupCall')
|
||||
|
||||
|
||||
def _get_entity_pair(entity_id, entities, cache,
|
||||
def _get_entity_pair(entity_id, entities,
|
||||
get_input_peer=get_input_peer):
|
||||
"""
|
||||
Returns ``(entity, input_entity)`` for the given entity ID.
|
||||
"""
|
||||
entity = entities.get(entity_id)
|
||||
try:
|
||||
input_entity = cache[entity_id]
|
||||
except KeyError:
|
||||
# KeyError is unlikely, so another TypeError won't hurt
|
||||
try:
|
||||
input_entity = get_input_peer(entity)
|
||||
except TypeError:
|
||||
input_entity = None
|
||||
input_entity = get_input_peer(entity)
|
||||
except TypeError:
|
||||
input_entity = None
|
||||
|
||||
return entity, input_entity
|
||||
|
||||
|
Reference in New Issue
Block a user