Fix _update_loop could get stuck in an infinite loop with no feedback

This commit is contained in:
Lonami Exo 2021-09-19 17:08:34 +02:00
parent 81b4957d9b
commit d33402f02e

View File

@ -173,16 +173,17 @@ async def _update_loop(self: 'TelegramClient'):
rnd = lambda: random.randrange(-2**63, 2**63) rnd = lambda: random.randrange(-2**63, 2**63)
while self.is_connected(): while self.is_connected():
try: try:
await asyncio.wait_for( await asyncio.wait_for(self.run_until_disconnected(), timeout=60)
self.disconnected, timeout=60
)
continue # We actually just want to act upon timeout continue # We actually just want to act upon timeout
except asyncio.TimeoutError: except asyncio.TimeoutError:
pass pass
except asyncio.CancelledError: except asyncio.CancelledError:
return return
except Exception: except Exception as e:
continue # Any disconnected exception should be ignored # Any disconnected exception should be ignored (or it may hint at
# another problem, leading to an infinite loop, hence the logging call)
self._log[__name__].info('Exception waiting on a disconnect: %s', e)
continue
# Check if we have any exported senders to clean-up periodically # Check if we have any exported senders to clean-up periodically
await self._clean_exported_senders() await self._clean_exported_senders()