Replies: 2 comments
-
EDIT: Seems very much this is related to this: |
Beta Was this translation helpful? Give feedback.
0 replies
-
EDIT: My own fault. My exception handler had a typo and caused another (unhandled) Exception, which would then not be caught by anyone, and cause the bot loop to exit. |
Beta Was this translation helpful? Give feedback.
0 replies
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
-
I did some robustness testing. For this the bot sends messages to the group once a second (as long as the bot is part of the group), and during that I'm repeatedly adding and removing the bot to/from the group in telegram. So it's a flurry of messages and add/remove.
When removing the bot from the group, sometimes I get the following log message:
2024-03-30 19:01:45,547 - telegram.ext.Application - WARNING - Fetching updates got a asyncio.CancelledError. Ignoring as this task may onlybe closed via Application.stop.
After this, the bot does not react anymore to things happening in the group, and needs to be restarted to recover.
The message sending (one per second) to the group I'm doing from within a try-catch-block, in an independent asyncio task. This means in theory it can run into a situation where PTB has just gone into awaiting the send, when the 'kicked from group' becomes effective. My plan was to catch this race condition (unavoidable, I guess) with the try-catch-block after it happened. But that catch never fires, I only get the log message. I've added error handlers (
add_error_handler()
, and in additionerror_callback
set as param instart_polling()
call to catch network errors), but these also don't catch anything.Is this a bug? Or am I misusing some API here? I'm wondering why I'm getting the mentioned error during "Fetching updates" (according to the error message), when this is (apparently) triggered by sending a message? Or is this the way PTB works internally?
Beta Was this translation helpful? Give feedback.
All reactions