a clean exit

jak nospam at please.ty
Fri Jul 23 04:55:12 EDT 2021


Hello everybody,
I wrote a bot for telegram which consists of some processes of which the
main ones are:
- the main process: a list of callback functions
- a second process: managed with a message queue
- a third process: started by the library I use (python-telegram-bot)
which is used for the event/error log ('logging' module).
The problem is that sometimes I get an error from the library (python-
telegram-bot) via logging that my bot has no way of intercepting. The
error is "connection reset by pear" after which my program is no longer
called and I need to restart it. Typically this happens when Telegram
runs an update.
In any case I can know this error because, to write a log in a telegram
channel, I inherit the 'emit' function of the 'logging.Handler' class.
Hoping to have explained clearly enough the context in which the program
receives information about the error (we are inside a process not
launched directly from the main program), my question is: do you have
advice on how I can close my program in the way as clean as possible in
a easy way?

Thanks in advance.


More information about the Python-list mailing list