mirror of
https://github.com/LonamiWebs/Telethon.git
synced 2024-11-22 01:16:35 +03:00
Handle ValueError during get_channel_difference
This commit is contained in:
parent
396594060b
commit
4b151fbce9
|
@ -279,7 +279,7 @@ class UpdateMethods:
|
||||||
self._log[__name__].info('Getting difference for channel updates')
|
self._log[__name__].info('Getting difference for channel updates')
|
||||||
try:
|
try:
|
||||||
diff = await self(get_diff)
|
diff = await self(get_diff)
|
||||||
except errors.PersistentTimestampOutdatedError:
|
except (errors.PersistentTimestampOutdatedError, errors.PersistentTimestampInvalidError, ValueError) as e:
|
||||||
# According to Telegram's docs:
|
# According to Telegram's docs:
|
||||||
# "Channel internal replication issues, try again later (treat this like an RPC_CALL_FAIL)."
|
# "Channel internal replication issues, try again later (treat this like an RPC_CALL_FAIL)."
|
||||||
# We can treat this as "empty difference" and not update the local pts.
|
# We can treat this as "empty difference" and not update the local pts.
|
||||||
|
@ -291,23 +291,20 @@ class UpdateMethods:
|
||||||
#
|
#
|
||||||
# This is a bit hacky because MessageBox doesn't really have a way to "not update" the pts.
|
# This is a bit hacky because MessageBox doesn't really have a way to "not update" the pts.
|
||||||
# Instead we manually extract the previously-known pts and use that.
|
# Instead we manually extract the previously-known pts and use that.
|
||||||
self._log[__name__].warning(
|
#
|
||||||
'Getting difference for channel updates caused PersistentTimestampOutdated;'
|
# For PersistentTimestampInvalidError:
|
||||||
' ending getting difference prematurely until server issues are resolved'
|
|
||||||
)
|
|
||||||
self._message_box.end_channel_difference(
|
|
||||||
get_diff,
|
|
||||||
PrematureEndReason.TEMPORARY_SERVER_ISSUES,
|
|
||||||
self._mb_entity_cache
|
|
||||||
)
|
|
||||||
continue
|
|
||||||
except errors.PersistentTimestampInvalidError:
|
|
||||||
# Somehow our pts is either too new or the server does not know about this.
|
# Somehow our pts is either too new or the server does not know about this.
|
||||||
# We treat this as PersistentTimestampOutdatedError for now.
|
# We treat this as PersistentTimestampOutdatedError for now.
|
||||||
# TODO investigate why/when this happens and if this is the proper solution
|
# TODO investigate why/when this happens and if this is the proper solution
|
||||||
|
if isinstance(e, errors.PersistentTimestampOutdatedError):
|
||||||
|
reason = 'caused PersistentTimestampOutdated'
|
||||||
|
elif isinstance(e, errors.PersistentTimestampInvalidError):
|
||||||
|
reason = 'caused PersistentTimestampInvalidError'
|
||||||
|
else:
|
||||||
|
reason = 'is failing'
|
||||||
self._log[__name__].warning(
|
self._log[__name__].warning(
|
||||||
'Getting difference for channel updates caused PersistentTimestampInvalidError;'
|
'Getting difference for channel updates %s;'
|
||||||
' ending getting difference prematurely until server issues are resolved'
|
' ending getting difference prematurely until server issues are resolved', reason
|
||||||
)
|
)
|
||||||
self._message_box.end_channel_difference(
|
self._message_box.end_channel_difference(
|
||||||
get_diff,
|
get_diff,
|
||||||
|
|
Loading…
Reference in New Issue
Block a user