mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 09:26:37 +03:00
Handle ConnectionError during update handling
This commit is contained in:
parent
2ffac2dcdb
commit
0c868065c7
|
@ -290,6 +290,13 @@ class UpdateMethods:
|
||||||
self._log[__name__].info('Cannot get difference since the account is not logged in: %s', type(e).__name__)
|
self._log[__name__].info('Cannot get difference since the account is not logged in: %s', type(e).__name__)
|
||||||
self._message_box.end_difference()
|
self._message_box.end_difference()
|
||||||
continue
|
continue
|
||||||
|
except OSError as e:
|
||||||
|
# Network is likely down, but it's unclear for how long.
|
||||||
|
# If disconnect is called this task will be cancelled along with the sleep.
|
||||||
|
# If disconnect is not called, getting difference should be retried after a few seconds.
|
||||||
|
self._log[__name__].info('Cannot get difference since the network is down: %s: %s', type(e).__name__, e)
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
continue
|
||||||
updates, users, chats = self._message_box.apply_difference(diff, self._mb_entity_cache)
|
updates, users, chats = self._message_box.apply_difference(diff, self._mb_entity_cache)
|
||||||
if updates:
|
if updates:
|
||||||
self._log[__name__].info('Got difference for account updates')
|
self._log[__name__].info('Got difference for account updates')
|
||||||
|
@ -351,6 +358,13 @@ class UpdateMethods:
|
||||||
self._mb_entity_cache
|
self._mb_entity_cache
|
||||||
)
|
)
|
||||||
continue
|
continue
|
||||||
|
except OSError as e:
|
||||||
|
self._log[__name__].info(
|
||||||
|
'Cannot get difference for channel %d since the network is down: %s: %s',
|
||||||
|
get_diff.channel.channel_id, type(e).__name__, e
|
||||||
|
)
|
||||||
|
await asyncio.sleep(5)
|
||||||
|
continue
|
||||||
|
|
||||||
updates, users, chats = self._message_box.apply_channel_difference(get_diff, diff, self._mb_entity_cache)
|
updates, users, chats = self._message_box.apply_channel_difference(get_diff, diff, self._mb_entity_cache)
|
||||||
if updates:
|
if updates:
|
||||||
|
|
Loading…
Reference in New Issue
Block a user