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.
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.
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).
Fixes#1426. Not entirely happy with the new indirection layer,
but the original __call__ method is already a mess anyway and
the additional cost of an extra call should be neglible compared
to the actual IO.
Only the uses of `isinstance` against `InputPeer*` types were
reviewed. Notably, `utils` is exempt on this because it needs
to deal with everything on a case-by-case basis.
Since the addition of `*FromMessage` peers, any manual `isinstance`
checks to determine the type were prone to breaking or being
forgotten to be updated, so a common `helpers._entity_type()`
method was made to share this logic.
Since the conversion to `Peer` would be too expensive, a simpler
check against the name is made, which should be fast and cheap.
Plenty of unnecessary exceptions were being raised and caught when
the input parameters were already correct. Furthermore, since
8abc7ade22, the in-disk cache was no
longer being used (so using usernames always reached out to memory).
This one in particular may happen when iterating over messages,
perhaps more likely to happen if the group was created in a
different data center.
A small sleep of a few seconds also greatly increases the
chances of the error going away.
* Create `_NOT_A_REQUEST` when needed. Currently, modifications
in the raised exception would be "global".
* `retries` parameters were actually attempts. This has been fixed
to actually be the amount of retries, so 0 now means don't retry.
* Helper function to deal with retries instead of using a range with
different styles every time.