Commit Graph

136 Commits

Author SHA1 Message Date
Lonami Exo
b0f9fd1f25 Except all types of timeout error
Closes #4172.
2023-08-18 18:36:30 +02:00
Lonami Exo
438aff3545 Handle FloodWaitError in update loop
Likely temporary server issues, since getDifference should
realistically not fail with flood waits. In any case,
stopping early until the problem is resolved is the correct
approach.
2023-07-21 23:01:12 +02:00
Lonami Exo
4eef9b52c9 Handle sqlite3.OperationalError in update loop 2023-07-21 22:56:16 +02:00
Lonami Exo
c3bddf9440 Add missing formatting arg in logging call
Noticed in #4123.
2023-06-02 23:04:14 +02:00
Lonami Exo
2889bd5bf3 except and propagate TypeNotFoundError during update handling 2023-05-03 17:56:13 +02:00
Lonami Exo
88bc6a46a6 Store self user in entity cache 2023-04-06 13:58:26 +02:00
Lonami Exo
97b0ba6707 Flush in-memory cache to session after a limit is reached
Should fully close #3989.
Should help with #3235.
2023-04-06 13:45:12 +02:00
Lonami Exo
f9001bc8e0 Include Telethon version on fatal errors during updates
Since a lot of people don't mention the version when reporting
issues, it makes it hard to determine whether it's already been
fixed or not.
2023-04-06 13:25:47 +02:00
Kacnep89
68ea208b43
Periodically save update state (#4071) 2023-03-28 19:00:36 +02:00
Lonami Exo
516a2e7435 Handle timeout error during getDifference
Closes #4043.
2023-03-12 17:46:25 +01:00
Lonami Exo
fb97a8aa87 Propagate account being logged-out errors
Should close #4016.
2023-01-11 20:30:33 +01:00
Lonami Exo
5080715565 Change updates add_done_callback to discard tasks more reliably
See #3235. This should help tone down memory usage a little.
2022-12-16 08:34:01 +01:00
Lonami Exo
0c868065c7 Handle ConnectionError during update handling 2022-10-25 12:28:40 +02:00
Alfian Pangetsu
908375ac42
Fix get_running_loop usage in Python3.6 (#3941)
Closes #3939.
2022-10-02 19:05:11 +02:00
Lonami Exo
d2b1c3ec5f Lower severity of some log messages during update handling
Some people were complaining that their logs were being spammed by it.
2022-10-02 16:07:14 +02:00
Lonami Exo
105a7a7c56 Log channel ID when getting their difference 2022-09-27 11:31:26 +02:00
Lonami Exo
c975b566a1 Handle ServerError while getting difference
Closes #3870.
2022-09-21 12:17:24 +02:00
Lonami Exo
49bdb762c9 Re-raise unhandled errors that occur during update handling
This should help the situation in #3870.
2022-09-21 12:13:21 +02:00
Lonami Exo
243f58c331 Handle auth errors during get difference 2022-09-20 11:35:59 +02:00
Lonami Exo
50aa92ebde Handle CancelledError inside update loop
This error is not really unexpected, since the library uses it to
cancel the task during disconnect.

Closes #3921.
2022-09-14 17:11:13 +02:00
Lonami Exo
7d4424ac2b Make use of AlbumHack for all albums
Closes #3916.

The new MessageBox system is not designed with "albums come in the
same updates container" in mind (in fact, there was a note about this).

This version was also not intended to be published to PyPi, but it is,
so a workaround must be made for events.Album to remain working.

In essence, AlbumHack will always be used even if it technically did not
need to be used previously. This will cause a small delay for those
updates, but it should not be a major issue.
2022-09-14 16:53:56 +02:00
Lonami Exo
7d21b40401 Revert "Make sessions async"
This reverts commit d2de0f3aca.
2022-08-30 12:32:21 +02:00
Lonami Exo
df96ead0ab Also except ChannelInvalidError during get_diff
This change comes from here:
2166d913e6
2022-08-30 12:07:14 +02:00
Lonami Exo
4b151fbce9 Handle ValueError during get_channel_difference 2022-08-16 12:09:21 +02:00
Lonami Exo
dd55e7c748 Prevent double-logging of 'timeout for updates' 2022-08-11 10:53:21 +02:00
Lonami Exo
378ccd17bf Call catch_up before processing updates if the user wants so 2022-05-25 15:31:39 +02:00
Lonami Exo
6005585764 Don't crash if periodic session access fails
If saving every minute or new entities fails, it's not fatal.
Other places are not checked because it is more critical for
information to be saved, such as disconnect, where we want to
crash if the session cannot be accessed.
2022-05-23 14:02:56 +02:00
Lonami Exo
06b0ae56d4 Treat invalid pts as outdated pts 2022-05-23 13:56:10 +02:00
Lonami Exo
f50b2f5d61 Handle bans when getting difference 2022-05-23 11:41:59 +02:00
Lonami Exo
dfce1f53a8 Handle PersistentTimestampOutdatedError 2022-05-23 11:10:46 +02:00
Lonami Exo
a5c3df2743 Attempt to load and save MessageBox state 2022-05-13 17:40:03 +02:00
Lonami Exo
db09a92bc5 Make use of the new MessageBox 2022-05-13 13:17:16 +02:00
Tulir Asokan
d2de0f3aca Make sessions async
SQLiteSession is not updated, don't try to use it
2022-05-12 10:36:10 +02:00
Lonami Exo
2cb6cd5dad Change the way no_updates mode is enabled
See discussion on https://github.com/LonamiWebs/Telethon/commit/49713b2.

The problem with the automatic approach is that some scripts may do
some "fancier" things with the way they register updates, so it was
prone to failure (a handler could be added but since the last request
was without updates, nothing would be received).

This new approach is a bit more annoying to opt-into but also more
explicit.
2021-08-29 12:14:03 +02:00
alexkoay
196cef66fd
Fix typehint for callback in UpdateMethods (#3119) 2021-08-03 18:33:46 +02:00
Lonami Exo
0997e3fa9f Remove _log_exc workaround and NullHandler
It was added back in bfc408b probably due to a misunderstanding of
https://docs.python.org/3/howto/logging.html#configuring-logging-for-a-library.

The default behaviour of logging WARNING and above is good and
desirable (hiding unhandled exceptions in update handlers by default
was a big, accidental mistake). NullHandler is used to *prevent*
this good default, so it shouldn't be used in the first place.
2021-02-02 20:47:02 +01:00
Lonami Exo
b88ec4b814 Print unhandled errors to stderr if logging is not configured
This should mitigate "the code doesn't work but there are no errors"
situations. Users not wanting this behaviour can configure logging
with a high-enough level that won't print anything, or set a filter.
2021-01-30 13:47:28 +01:00
Lonami Exo
de7cf03ba7 Stop storing asyncio loop in TelegramClient
The loop parameter was ignored because it shouldn't be used, but
the fact it still stored the current loop on creation messes up
with asyncio.run.
2021-01-18 22:59:19 +01:00
Lonami Exo
becfe2ce7a Start reconnect if a second ping is sent without a pong for the first
May help with #1564.
2020-12-11 17:18:25 +01:00
vegeta1k95
39e899294f
Fix unhandled ValueError inside _dispatch_update() task (#1615) 2020-11-04 09:58:20 +01:00
vegeta1k95
d0faaa2ead
Fix internal get_me() was not expecting network errors (#1594) 2020-10-11 09:33:05 +02:00
Lonami Exo
cb92a40156 Add additional asserts to debug issue with peer empty channels 2020-10-05 13:58:04 +02:00
Lonami Exo
4321153b06 Correctly emulate old to_id behaviour 2020-10-02 10:23:04 +02:00
apepenkov
2a114917f1
Fix AlbumHack in combination with events.Raw (#1555) 2020-09-10 16:25:44 +02:00
Lonami Exo
1c3e7dda01 Avoid explicitly passing the loop to asyncio
This behaviour is deprecated and will be removed in future versions
of Python. Technically, it could be considered a bug (invalid usage
causing different behaviour from the expected one), and in practice
it should not break much code (because .get_event_loop() would likely
be the same event loop anyway).
2020-07-25 18:39:35 +02:00
Lonami Exo
4b933069f1 Add hacks to properly handle events.Album from other DCs
Fixes #1479.
2020-06-06 21:01:02 +02:00
Lonami Exo
faf7263d8f Handle RPC errors on auto-get_difference
Closes #1428.
2020-06-06 14:04:14 +02:00
Lonami Exo
bfa995d52b Don't crash when receiving updates prior to login
Fixes #1467, and enables #1471.
2020-06-05 21:17:09 +02:00
JuniorJPDJ
634bc3a8bd
Allow event's func to be async (#1461)
Fixes #1344.
2020-05-16 09:58:37 +02:00
Lonami Exo
d0f937bcb6 Don't disconnect borrowed senders immediately (#1364) 2020-04-05 12:34:33 +02:00