Skip to content

Commit

Permalink
Don't unnecessarily refetch the sender twice
Browse files Browse the repository at this point in the history
  • Loading branch information
Lonami committed Oct 3, 2022
1 parent 299b090 commit db29e9b
Showing 1 changed file with 8 additions and 5 deletions.
13 changes: 8 additions & 5 deletions telethon/tl/custom/sendergetter.py
Original file line number Diff line number Diff line change
Expand Up @@ -46,11 +46,14 @@ async def get_sender(self):
# cached information, they may use the property instead.
if (self._sender is None or getattr(self._sender, 'min', None)) \
and await self.get_input_sender():
try:
self._sender =\
await self._client.get_entity(self._input_sender)
except ValueError:
await self._refetch_sender()
# self.get_input_sender may refresh in which case the sender may no longer be min
# However it could still incur a cost so the cheap check is done twice instead.
if self._sender is None or getattr(self._sender, 'min', None):
try:
self._sender =\
await self._client.get_entity(self._input_sender)
except ValueError:
await self._refetch_sender()
return self._sender

@property
Expand Down

0 comments on commit db29e9b

Please sign in to comment.