I am writing some sort of informational bot and I need to handle the script termination event both in Windows (the system I use for development) and Linux (server).
I have tried the variant with signal module, but it did not work.
signal.signal(signal.SIGTERM, sigterm_handler)
I need to close the connection gracefully upon exit, shutdown the connection with database and so on.
What is the most correct way to handle the script termination event in both OS (Windows/Linux)?
Thanks.